mirror of
https://github.com/fmang/opustags.git
synced 2025-10-16 19:00:02 +02:00
ModificationTagsHandler: small optimization
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user