From ed7263ee3e9b8e03a421ea6619f08510e24bd0d7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 1 Jul 2022 11:18:17 +0200 Subject: [PATCH] decoder/OpusTags: use std::string_view --- src/decoder/plugins/OpusTags.cxx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/decoder/plugins/OpusTags.cxx b/src/decoder/plugins/OpusTags.cxx index fdab9d6e2..9d543af56 100644 --- a/src/decoder/plugins/OpusTags.cxx +++ b/src/decoder/plugins/OpusTags.cxx @@ -26,14 +26,16 @@ #include "util/ASCII.hxx" #include "tag/ReplayGainInfo.hxx" #include "util/NumberParser.hxx" +#include "util/StringCompare.hxx" #include "util/StringSplit.hxx" -#include "util/StringView.hxx" #include +using std::string_view_literals::operator""sv; + gcc_pure static TagType -ParseOpusTagName(StringView name) noexcept +ParseOpusTagName(std::string_view name) noexcept { TagType type = tag_name_parse_i(name); if (type != TAG_NUM_OF_ITEM_TYPES) @@ -43,19 +45,20 @@ ParseOpusTagName(StringView name) noexcept } static void -ScanOneOpusTag(StringView name, StringView value, +ScanOneOpusTag(std::string_view name, std::string_view value, ReplayGainInfo *rgi, TagHandler &handler) noexcept { if (handler.WantPicture() && - name.EqualsIgnoreCase("METADATA_BLOCK_PICTURE")) + StringIsEqualIgnoreCase(name, "METADATA_BLOCK_PICTURE"sv)) return ScanVorbisPicture(value, handler); - if (value.size >= 4096) + if (value.size() >= 4096) /* ignore large values */ return; - if (rgi != nullptr && name.EqualsIgnoreCase("R128_TRACK_GAIN")) { + if (rgi != nullptr && + StringIsEqualIgnoreCase(name, "R128_TRACK_GAIN"sv)) { /* R128_TRACK_GAIN is a Q7.8 fixed point number in dB */ @@ -64,7 +67,7 @@ ScanOneOpusTag(StringView name, StringView value, if (endptr > value.begin() && endptr == value.end()) rgi->track.gain = float(l) / 256.0f; } else if (rgi != nullptr && - name.EqualsIgnoreCase("R128_ALBUM_GAIN")) { + StringIsEqualIgnoreCase(name, "R128_ALBUM_GAIN"sv)) { /* R128_ALBUM_GAIN is a Q7.8 fixed point number in dB */