Skip to content

Commit

Permalink
use erase remove
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Jan 6, 2025
1 parent a2b6d6d commit d13712e
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/exif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,16 +644,10 @@ WriteMethod ExifParser::encode(Blob& blob, const byte* pData, size_t size, ByteO
}

// Delete unknown tags larger than 4kB and known tags larger than 20kB.
for (auto tag_iter = exifData.begin(); tag_iter != exifData.end();) {
if ((tag_iter->size() > 4096 && tag_iter->tagName().substr(0, 2) == "0x") || tag_iter->size() > 20480) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Exif tag " << tag_iter->key() << " not encoded\n";
#endif
tag_iter = exifData.erase(tag_iter);
} else {
++tag_iter;
}
}
auto f = [](const auto& tag) {
return (tag.size() > 4096 && tag.tagName().substr(0, 2) == "0x") || tag.size() > 20480;
};
exifData.erase(std::remove_if(exifData.begin(), exifData.end(), f), exifData.end());

// Encode the remaining Exif tags again, don't care if it fits this time
MemIo mio2;
Expand Down

0 comments on commit d13712e

Please sign in to comment.