decoder/OpusReader: use std::string_view

This commit is contained in:
Max Kellermann 2022-07-01 11:16:35 +02:00
parent e10b15010c
commit 671b7e079f
2 changed files with 8 additions and 8 deletions

View File

@ -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};
}

View File

@ -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);