summaryrefslogtreecommitdiff
path: root/indra/llcommon/llsdutil.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-07-05 19:18:09 +0300
committerGitHub <noreply@github.com>2024-07-05 19:18:09 +0300
commit958f7812839160247207c01e78b90f1935022ab3 (patch)
tree6ec615eb07b26a2ac2b07d747515847f8fdad0bd /indra/llcommon/llsdutil.cpp
parentb099dbef27f2af47a421bb9848cfbca1aaa08327 (diff)
parent1296afd96a74877feb91690ec8dcd99b225554b8 (diff)
Merge pull request #1930 from RyeMutt/llsd-opts
Introduce move support and string_view to LLSD
Diffstat (limited to 'indra/llcommon/llsdutil.cpp')
-rw-r--r--indra/llcommon/llsdutil.cpp21
1 files changed, 10 insertions, 11 deletions
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<U8> 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<U8> 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<U8> 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<U8> 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<U8> 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<U8> 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<U8> 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<U8> 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: