From 4086190c80f51503ff99e1a551ae760e99781a44 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 4 Jan 2024 21:04:15 +0100 Subject: [PATCH] decoder/OpusTags: use ParseInteger() --- src/decoder/plugins/OpusTags.cxx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/decoder/plugins/OpusTags.cxx b/src/decoder/plugins/OpusTags.cxx index e42fa4ec4..26b6c09cf 100644 --- a/src/decoder/plugins/OpusTags.cxx +++ b/src/decoder/plugins/OpusTags.cxx @@ -9,7 +9,7 @@ #include "tag/ParseName.hxx" #include "util/ASCII.hxx" #include "tag/ReplayGainInfo.hxx" -#include "util/CNumberParser.hxx" +#include "util/NumberParser.hxx" #include "util/StringCompare.hxx" #include "util/StringSplit.hxx" @@ -46,19 +46,15 @@ ScanOneOpusTag(std::string_view name, std::string_view value, /* R128_TRACK_GAIN is a Q7.8 fixed point number in dB */ - const char *endptr; - const auto l = ParseInt64(value, &endptr, 10); - if (endptr > value.begin() && endptr == value.end()) - rgi->track.gain = float(l) / 256.0f; + if (const auto i = ParseInteger(value)) + rgi->track.gain = float(*i) / 256.0f; } else if (rgi != nullptr && StringIsEqualIgnoreCase(name, "R128_ALBUM_GAIN"sv)) { /* R128_ALBUM_GAIN is a Q7.8 fixed point number in dB */ - const char *endptr; - const auto l = ParseInt64(value, &endptr, 10); - if (endptr > value.begin() && endptr == value.end()) - rgi->album.gain = float(l) / 256.0f; + if (const auto i = ParseInteger(value)) + rgi->album.gain = float(*i) / 256.0f; } handler.OnPair(name, value);