From 671b7e079fbe5d0d1b3d654850fbe8d5706dd904 Mon Sep 17 00:00:00 2001 From: Max Kellermann <max.kellermann@gmail.com> Date: Fri, 1 Jul 2022 11:16:35 +0200 Subject: [PATCH] decoder/OpusReader: use std::string_view --- src/decoder/plugins/OpusReader.hxx | 9 ++++----- src/decoder/plugins/OpusTags.cxx | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/decoder/plugins/OpusReader.hxx b/src/decoder/plugins/OpusReader.hxx index cb8a1229b..f199d7a7b 100644 --- a/src/decoder/plugins/OpusReader.hxx +++ b/src/decoder/plugins/OpusReader.hxx @@ -20,10 +20,9 @@ #ifndef MPD_OPUS_READER_HXX #define MPD_OPUS_READER_HXX -#include "util/StringView.hxx" - #include <algorithm> #include <cstdint> +#include <string_view> #include <string.h> @@ -83,14 +82,14 @@ public: return ReadWord(length) && Skip(length); } - constexpr StringView ReadString() noexcept { + constexpr std::string_view ReadString() noexcept { uint32_t length; if (!ReadWord(length)) - return nullptr; + return {}; const char *src = (const char *)Read(length); if (src == nullptr) - return nullptr; + return {}; return {src, length}; } diff --git a/src/decoder/plugins/OpusTags.cxx b/src/decoder/plugins/OpusTags.cxx index f7a44c19b..fdab9d6e2 100644 --- a/src/decoder/plugins/OpusTags.cxx +++ b/src/decoder/plugins/OpusTags.cxx @@ -26,6 +26,7 @@ #include "util/ASCII.hxx" #include "tag/ReplayGainInfo.hxx" #include "util/NumberParser.hxx" +#include "util/StringSplit.hxx" #include "util/StringView.hxx" #include <cstdint> @@ -104,11 +105,11 @@ ScanOpusTags(const void *data, size_t size, while (n-- > 0) { const auto s = r.ReadString(); - if (s == nullptr) + if (s.data() == nullptr) return false; - const auto split = s.Split('='); - if (split.first.empty() || split.second.IsNull()) + const auto split = Split(s, '='); + if (split.first.empty() || split.second.data() == nullptr) continue; ScanOneOpusTag(split.first, split.second, rgi, handler);