ModificationTagsHandler: small optimization

This commit is contained in:
rr-
2016-02-24 23:13:16 +01:00
parent 7b6ad95b35
commit 221c314625
2 changed files with 6 additions and 0 deletions

View File

@@ -22,6 +22,9 @@ std::string ModificationTagsHandler::get_tag_value() const
bool ModificationTagsHandler::edit_impl(Tags &tags)
{
if (tags.contains(tag_key) && tags.get(tag_key) == tag_value)
return false;
tags.set(tag_key, tag_value);
return true;
}

View File

@@ -27,4 +27,7 @@ TEST_CASE("Modification tags handler test")
REQUIRE(handler2.edit(streamno, tags));
REQUIRE(tags.get_all().size() == 2);
REQUIRE(tags.get(other_tag_key) == new_value);
// setting existing keys reports no modifications if values are the same
REQUIRE(!handler2.edit(streamno, tags));
}