You need to sign in or sign up before continuing.
Commit 8e0d8109 authored by Max Kellermann's avatar Max Kellermann

tag/MixRamp: use StringView in ParseMixRampTagTemplate()

parent 0f1e13d9
...@@ -21,6 +21,7 @@ ...@@ -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> ...@@ -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);
const auto end = t["mixramp_end"];
if (!start.IsNull()) {
info.SetEnd(std::string(end.data, end.size));
return true; return true;
} else }
return false;
return false;
} }
bool bool
...@@ -52,7 +55,7 @@ ParseMixRampTag(MixRampInfo &info, const char *name, const char *value) ...@@ -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) ...@@ -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);
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment