From 1296afd96a74877feb91690ec8dcd99b225554b8 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 4 Jul 2024 13:02:34 -0400 Subject: Reduce LLSD::Binary temporaries --- indra/llcommon/llsdutil.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'indra/llcommon/llsdutil.cpp') diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp index dd3a58c26d..34aa0bc070 100644 --- a/indra/llcommon/llsdutil.cpp +++ b/indra/llcommon/llsdutil.cpp @@ -51,7 +51,7 @@ // U32 LLSD ll_sd_from_U32(const U32 val) { - std::vector v; + LLSD::Binary v; U32 net_order = htonl(val); v.resize(4); @@ -63,7 +63,7 @@ LLSD ll_sd_from_U32(const U32 val) U32 ll_U32_from_sd(const LLSD& sd) { U32 ret; - std::vector v = sd.asBinary(); + const LLSD::Binary& v = sd.asBinary(); if (v.size() < 4) { return 0; @@ -76,7 +76,7 @@ U32 ll_U32_from_sd(const LLSD& sd) //U64 LLSD ll_sd_from_U64(const U64 val) { - std::vector v; + LLSD::Binary v; U32 high, low; high = (U32)(val >> 32); @@ -94,7 +94,7 @@ LLSD ll_sd_from_U64(const U64 val) U64 ll_U64_from_sd(const LLSD& sd) { U32 high, low; - std::vector v = sd.asBinary(); + const LLSD::Binary& v = sd.asBinary(); if (v.size() < 8) { @@ -112,7 +112,7 @@ U64 ll_U64_from_sd(const LLSD& sd) // IP Address (stored in net order in a U32, so don't need swizzling) LLSD ll_sd_from_ipaddr(const U32 val) { - std::vector v; + LLSD::Binary v; v.resize(4); memcpy(&(v[0]), &val, 4); /* Flawfinder: ignore */ @@ -123,7 +123,7 @@ LLSD ll_sd_from_ipaddr(const U32 val) U32 ll_ipaddr_from_sd(const LLSD& sd) { U32 ret; - std::vector v = sd.asBinary(); + const LLSD::Binary& v = sd.asBinary(); if (v.size() < 4) { return 0; @@ -135,17 +135,17 @@ U32 ll_ipaddr_from_sd(const LLSD& sd) // Converts an LLSD binary to an LLSD string LLSD ll_string_from_binary(const LLSD& sd) { - std::vector value = sd.asBinary(); + const LLSD::Binary& value = sd.asBinary(); std::string str; str.resize(value.size()); - memcpy(&str[0], &value[0], value.size()); + memcpy(&str[0], value.data(), value.size()); return str; } // Converts an LLSD string to an LLSD binary LLSD ll_binary_from_string(const LLSD& sd) { - std::vector binary_value; + LLSD::Binary binary_value; std::string string_value = sd.asString(); for (const U8 c : string_value) @@ -990,8 +990,7 @@ LLSD llsd_clone(LLSD value, LLSD filter) case LLSD::TypeBinary: { - LLSD::Binary bin(value.asBinary().begin(), value.asBinary().end()); - clone = LLSD::Binary(bin); + clone = LLSD::Binary(value.asBinary().begin(), value.asBinary().end()); break; } default: -- cgit v1.2.3