From c98fba7cc4833a80ee8a9bf2c01a48b6550d0bf2 Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Sun, 30 Jan 2022 16:55:09 +0100 Subject: [PATCH] APE: Do not create map entry if looked up tag does not exist (#931) --- taglib/ape/apetag.cpp | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp index 5d6c521b..4235f73e 100644 --- a/taglib/ape/apetag.cpp +++ b/taglib/ape/apetag.cpp @@ -116,51 +116,44 @@ ByteVector APE::Tag::fileIdentifier() String APE::Tag::title() const { - if(d->itemListMap["TITLE"].isEmpty()) - return String(); - return d->itemListMap["TITLE"].values().toString(); + Item value = d->itemListMap.value("TITLE"); + return value.isEmpty() ? String() : value.values().toString(); } String APE::Tag::artist() const { - if(d->itemListMap["ARTIST"].isEmpty()) - return String(); - return d->itemListMap["ARTIST"].values().toString(); + Item value = d->itemListMap.value("ARTIST"); + return value.isEmpty() ? String() : value.values().toString(); } String APE::Tag::album() const { - if(d->itemListMap["ALBUM"].isEmpty()) - return String(); - return d->itemListMap["ALBUM"].values().toString(); + Item value = d->itemListMap.value("ALBUM"); + return value.isEmpty() ? String() : value.values().toString(); } String APE::Tag::comment() const { - if(d->itemListMap["COMMENT"].isEmpty()) - return String(); - return d->itemListMap["COMMENT"].values().toString(); + Item value = d->itemListMap.value("COMMENT"); + return value.isEmpty() ? String() : value.values().toString(); } String APE::Tag::genre() const { - if(d->itemListMap["GENRE"].isEmpty()) - return String(); - return d->itemListMap["GENRE"].values().toString(); + Item value = d->itemListMap.value("GENRE"); + return value.isEmpty() ? String() : value.values().toString(); } unsigned int APE::Tag::year() const { - if(d->itemListMap["YEAR"].isEmpty()) - return 0; - return d->itemListMap["YEAR"].toString().toInt(); + Item value = d->itemListMap.value("YEAR"); + return value.isEmpty() ? 0 : value.toString().toInt(); } unsigned int APE::Tag::track() const { - if(d->itemListMap["TRACK"].isEmpty()) - return 0; - return d->itemListMap["TRACK"].toString().toInt(); + Item value = d->itemListMap.value("TRACK"); + return value.isEmpty() ? 0 : value.toString().toInt(); } void APE::Tag::setTitle(const String &s)