tag/MixRamp: use StringView in ParseMixRampTagTemplate()

This commit is contained in:
Max Kellermann 2019-08-14 12:18:49 +02:00
parent 0f1e13d9ff
commit 8e0d810968
1 changed files with 14 additions and 11 deletions

View File

@ -21,6 +21,7 @@
#include "VorbisComment.hxx" #include "VorbisComment.hxx"
#include "MixRampInfo.hxx" #include "MixRampInfo.hxx"
#include "util/ASCII.hxx" #include "util/ASCII.hxx"
#include "util/StringView.hxx"
#include <assert.h> #include <assert.h>
@ -28,17 +29,19 @@ template<typename T>
static bool static bool
ParseMixRampTagTemplate(MixRampInfo &info, const T t) ParseMixRampTagTemplate(MixRampInfo &info, const T t)
{ {
const char *value; const auto start = t["mixramp_start"];
if (!start.IsNull()) {
if ((value = t["mixramp_start"]) != nullptr) { info.SetStart(std::string(start.data, start.size));
info.SetStart(value);
return true; return true;
} else if ((value = t["mixramp_end"]) != nullptr) { }
info.SetEnd(value);
return true;
} else
return false;
const auto end = t["mixramp_end"];
if (!start.IsNull()) {
info.SetEnd(std::string(end.data, end.size));
return true;
}
return false;
} }
bool bool
@ -52,7 +55,7 @@ ParseMixRampTag(MixRampInfo &info, const char *name, const char *value)
const char *value; const char *value;
gcc_pure gcc_pure
const char *operator[](const char *n) const noexcept { StringView operator[](const char *n) const noexcept {
return StringEqualsCaseASCII(name, n) return StringEqualsCaseASCII(name, n)
? value ? value
: nullptr; : nullptr;
@ -69,7 +72,7 @@ ParseMixRampVorbis(MixRampInfo &info, const char *entry)
const char *entry; const char *entry;
gcc_pure gcc_pure
const char *operator[](const char *n) const noexcept { StringView operator[](const char *n) const noexcept {
return vorbis_comment_value(entry, n); return vorbis_comment_value(entry, n);
} }
}; };