From 67df85135d85964158c374a540a87bdeef245e80 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 31 Oct 2022 17:25:32 -0700 Subject: [PATCH] early exit less indentation Signed-off-by: Rosen Penev --- src/tags_int.cpp | 14 ++++---------- src/xmp.cpp | 8 +++----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/tags_int.cpp b/src/tags_int.cpp index cfe46b90..8d61f7cc 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -2328,7 +2328,6 @@ bool isMakerIfd(IfdId ifdId) { } bool isExifIfd(IfdId ifdId) { - bool rc; switch (ifdId) { case IfdId::ifd0Id: case IfdId::exifId: @@ -2349,13 +2348,10 @@ bool isExifIfd(IfdId ifdId) { case IfdId::subImage9Id: case IfdId::subThumb1Id: case IfdId::panaRawId: - rc = true; - break; + return true; default: - rc = false; - break; + return false; } - return rc; } void taglist(std::ostream& os, IfdId ifdId) { @@ -2554,11 +2550,9 @@ std::ostream& printUcs2(std::ostream& os, const Value& value, const ExifData*) { // Strip trailing UCS-2 0-characters while (buf.size() >= 2) { - if (buf.read_uint8(buf.size() - 1) == 0 && buf.read_uint8(buf.size() - 2) == 0) { - buf.resize(buf.size() - 2); - } else { + if (buf.read_uint8(buf.size() - 1) != 0 || buf.read_uint8(buf.size() - 2) != 0) break; - } + buf.resize(buf.size() - 2); } std::string str(buf.c_str(), buf.size()); diff --git a/src/xmp.cpp b/src/xmp.cpp index db3e253b..f136f651 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -495,12 +495,10 @@ void XmpData::eraseFamily(XmpData::iterator& pos) { std::string key(pos->key()); std::vector keys; while (pos != xmpMetadata_.end()) { - if (Exiv2::Internal::startsWith(pos->key(), key)) { - keys.push_back(pos->key()); - pos++; - } else { + if (!Exiv2::Internal::startsWith(pos->key(), key)) break; - } + keys.push_back(pos->key()); + pos++; } // now erase the family! for (const auto& k : keys) {