Skip to content

Commit

Permalink
replace while loop with for range.
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Oct 27, 2022
1 parent 761acaf commit 3c80608
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4985,11 +4985,8 @@ void XmpProperties::unregisterNsUnsafe(const std::string& ns) {
void XmpProperties::unregisterNs() {
auto scoped_write_lock = std::scoped_lock(mutex_);
/// \todo check if we are not unregistering the first NS
auto i = nsRegistry_.begin();
while (i != nsRegistry_.end()) {
auto kill = i++;
unregisterNsUnsafe(kill->first);
}
for (const auto& k : nsRegistry_)
unregisterNsUnsafe(k.first);
}

std::string XmpProperties::prefix(const std::string& ns) {
Expand Down
10 changes: 4 additions & 6 deletions src/xmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "error.hpp"
#include "properties.hpp"
#include "types.hpp"
#include "utils.hpp"
#include "value.hpp"
#include "xmp_exiv2.hpp"

Expand Down Expand Up @@ -493,13 +494,10 @@ void XmpData::eraseFamily(XmpData::iterator& pos) {
// https://github.com/Exiv2/exiv2/issues/560
std::string key(pos->key());
std::vector<std::string> keys;
while (pos != xmpMetadata_.end()) {
if (pos->key().find(key) == 0) {
keys.push_back(pos->key());
pos++;
} else {
for (const auto& k : xmpMetadata_) {
if (!Exiv2::Internal::startsWith(k.key(), key))
break;
}
keys.push_back(k.key());
}
// now erase the family!
for (const auto& k : keys) {
Expand Down

0 comments on commit 3c80608

Please sign in to comment.