decoder/OpusReader: use std::string_view
This commit is contained in:
parent
e10b15010c
commit
671b7e079f
|
@ -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};
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue