Skip to content

Commit b5c6513

Browse files
committed
slightly simplify print0x009e
Avoid nested ifs. Signed-off-by: Rosen Penev <[email protected]>
1 parent 21fa9ab commit b5c6513

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/nikonmn_int.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,30 +3885,31 @@ std::ostream& Nikon3MakerNote::print0x009a(std::ostream& os, const Value& value,
38853885
}
38863886

38873887
std::ostream& Nikon3MakerNote::print0x009e(std::ostream& os, const Value& value, const ExifData*) {
3888-
if (value.count() != 10 || value.typeId() != unsignedShort) {
3888+
if (value.count() != 10 || value.typeId() != unsignedShort)
38893889
return os << value;
3890-
}
3891-
std::string s;
3890+
3891+
std::vector<std::string> sv;
38923892
bool trim = true;
3893+
38933894
for (int i = 9; i >= 0; --i) {
38943895
const auto l = value.toInt64(i);
38953896
if (i > 0 && l == 0 && trim)
38963897
continue;
38973898
if (l != 0)
38983899
trim = false;
3899-
if (s.empty()) {
3900-
if (auto td = Exiv2::find(nikonRetouchHistory, l))
3901-
s = stringFormat("{}{}", _(td->label_), s);
3902-
else
3903-
s = stringFormat("{} ({}) {}", _("Unknown"), l, s);
3904-
} else {
3905-
if (auto td = Exiv2::find(nikonRetouchHistory, l))
3906-
s = stringFormat("{}; {}", _(td->label_), s);
3907-
else
3908-
s = stringFormat("{} ({}) ; {}", _("Unknown"), l, s);
3909-
}
3900+
3901+
if (auto td = Exiv2::find(nikonRetouchHistory, l))
3902+
sv.emplace_back(_(td->label_));
3903+
else
3904+
sv.emplace_back(stringFormat("{} ({})", _("Unknown"), l));
3905+
}
3906+
3907+
if (!sv.empty()) {
3908+
std::copy(sv.begin(), sv.end() - 1, std::ostream_iterator<std::string>(os, "; "));
3909+
os << sv.back();
39103910
}
3911-
return os << s;
3911+
3912+
return os;
39123913
}
39133914

39143915
std::ostream& Nikon3MakerNote::printApertureLd4(std::ostream& os, const Value& value, const ExifData*) {

0 commit comments

Comments
 (0)