From: Otto Moerbeek Date: Tue, 24 Jun 2025 08:53:37 +0000 (+0200) Subject: Use get_view() instead of get_data() X-Git-Tag: rec-5.3.0-alpha1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15668%2Fhead;p=thirdparty%2Fpdns.git Use get_view() instead of get_data() Signed-off-by: Otto Moerbeek --- diff --git a/pdns/protozero-trace.hh b/pdns/protozero-trace.hh index 12fc115e8f..36fcaad53a 100644 --- a/pdns/protozero-trace.hh +++ b/pdns/protozero-trace.hh @@ -280,9 +280,9 @@ inline void encode(protozero::pbf_writer& writer, uint8_t field, const TraceID& inline TraceID decodeTraceID(protozero::pbf_reader& reader) { TraceID bytes; - auto [data, len] = reader.get_data(); - len = std::min(bytes.size(), static_cast(len)); - std::copy(data, data + len, bytes.begin()); + const auto data = reader.get_view(); + const auto len = std::min(bytes.size(), data.size()); + std::copy(data.data(), data.data() + len, bytes.begin()); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) return bytes; } @@ -294,9 +294,9 @@ inline void encode(protozero::pbf_writer& writer, uint8_t field, const SpanID& v inline SpanID decodeSpanID(protozero::pbf_reader& reader) { SpanID bytes; - auto [data, len] = reader.get_data(); - len = std::min(bytes.size(), static_cast(len)); - std::copy(data, data + len, bytes.begin()); + const auto data = reader.get_view(); + const auto len = std::min(bytes.size(), data.size()); + std::copy(data.data(), data.data() + len, bytes.begin()); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) return bytes; }