Reduce LLSD::Binary temporaries
parent
f6d2536e4f
commit
1296afd96a
|
|
@ -51,7 +51,7 @@
|
||||||
// U32
|
// U32
|
||||||
LLSD ll_sd_from_U32(const U32 val)
|
LLSD ll_sd_from_U32(const U32 val)
|
||||||
{
|
{
|
||||||
std::vector<U8> v;
|
LLSD::Binary v;
|
||||||
U32 net_order = htonl(val);
|
U32 net_order = htonl(val);
|
||||||
|
|
||||||
v.resize(4);
|
v.resize(4);
|
||||||
|
|
@ -63,7 +63,7 @@ LLSD ll_sd_from_U32(const U32 val)
|
||||||
U32 ll_U32_from_sd(const LLSD& sd)
|
U32 ll_U32_from_sd(const LLSD& sd)
|
||||||
{
|
{
|
||||||
U32 ret;
|
U32 ret;
|
||||||
std::vector<U8> v = sd.asBinary();
|
const LLSD::Binary& v = sd.asBinary();
|
||||||
if (v.size() < 4)
|
if (v.size() < 4)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -76,7 +76,7 @@ U32 ll_U32_from_sd(const LLSD& sd)
|
||||||
//U64
|
//U64
|
||||||
LLSD ll_sd_from_U64(const U64 val)
|
LLSD ll_sd_from_U64(const U64 val)
|
||||||
{
|
{
|
||||||
std::vector<U8> v;
|
LLSD::Binary v;
|
||||||
U32 high, low;
|
U32 high, low;
|
||||||
|
|
||||||
high = (U32)(val >> 32);
|
high = (U32)(val >> 32);
|
||||||
|
|
@ -94,7 +94,7 @@ LLSD ll_sd_from_U64(const U64 val)
|
||||||
U64 ll_U64_from_sd(const LLSD& sd)
|
U64 ll_U64_from_sd(const LLSD& sd)
|
||||||
{
|
{
|
||||||
U32 high, low;
|
U32 high, low;
|
||||||
std::vector<U8> v = sd.asBinary();
|
const LLSD::Binary& v = sd.asBinary();
|
||||||
|
|
||||||
if (v.size() < 8)
|
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)
|
// IP Address (stored in net order in a U32, so don't need swizzling)
|
||||||
LLSD ll_sd_from_ipaddr(const U32 val)
|
LLSD ll_sd_from_ipaddr(const U32 val)
|
||||||
{
|
{
|
||||||
std::vector<U8> v;
|
LLSD::Binary v;
|
||||||
|
|
||||||
v.resize(4);
|
v.resize(4);
|
||||||
memcpy(&(v[0]), &val, 4); /* Flawfinder: ignore */
|
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 ll_ipaddr_from_sd(const LLSD& sd)
|
||||||
{
|
{
|
||||||
U32 ret;
|
U32 ret;
|
||||||
std::vector<U8> v = sd.asBinary();
|
const LLSD::Binary& v = sd.asBinary();
|
||||||
if (v.size() < 4)
|
if (v.size() < 4)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -135,17 +135,17 @@ U32 ll_ipaddr_from_sd(const LLSD& sd)
|
||||||
// Converts an LLSD binary to an LLSD string
|
// Converts an LLSD binary to an LLSD string
|
||||||
LLSD ll_string_from_binary(const LLSD& sd)
|
LLSD ll_string_from_binary(const LLSD& sd)
|
||||||
{
|
{
|
||||||
std::vector<U8> value = sd.asBinary();
|
const LLSD::Binary& value = sd.asBinary();
|
||||||
std::string str;
|
std::string str;
|
||||||
str.resize(value.size());
|
str.resize(value.size());
|
||||||
memcpy(&str[0], &value[0], value.size());
|
memcpy(&str[0], value.data(), value.size());
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts an LLSD string to an LLSD binary
|
// Converts an LLSD string to an LLSD binary
|
||||||
LLSD ll_binary_from_string(const LLSD& sd)
|
LLSD ll_binary_from_string(const LLSD& sd)
|
||||||
{
|
{
|
||||||
std::vector<U8> binary_value;
|
LLSD::Binary binary_value;
|
||||||
|
|
||||||
std::string string_value = sd.asString();
|
std::string string_value = sd.asString();
|
||||||
for (const U8 c : string_value)
|
for (const U8 c : string_value)
|
||||||
|
|
@ -990,8 +990,7 @@ LLSD llsd_clone(LLSD value, LLSD filter)
|
||||||
|
|
||||||
case LLSD::TypeBinary:
|
case LLSD::TypeBinary:
|
||||||
{
|
{
|
||||||
LLSD::Binary bin(value.asBinary().begin(), value.asBinary().end());
|
clone = LLSD::Binary(value.asBinary().begin(), value.asBinary().end());
|
||||||
clone = LLSD::Binary(bin);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -2345,11 +2345,11 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLSD::Binary pos = mdl[i]["Position"];
|
const LLSD::Binary& pos = mdl[i]["Position"].asBinary();
|
||||||
LLSD::Binary norm = mdl[i]["Normal"];
|
const LLSD::Binary& norm = mdl[i]["Normal"].asBinary();
|
||||||
LLSD::Binary tangent = mdl[i]["Tangent"];
|
const LLSD::Binary& tangent = mdl[i]["Tangent"].asBinary();
|
||||||
LLSD::Binary tc = mdl[i]["TexCoord0"];
|
const LLSD::Binary& tc = mdl[i]["TexCoord0"].asBinary();
|
||||||
LLSD::Binary idx = mdl[i]["TriangleList"];
|
const LLSD::Binary& idx = mdl[i]["TriangleList"].asBinary();
|
||||||
|
|
||||||
//copy out indices
|
//copy out indices
|
||||||
auto num_indices = idx.size() / 2;
|
auto num_indices = idx.size() / 2;
|
||||||
|
|
@ -2538,7 +2538,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLSD::Binary weights = mdl[i]["Weights"];
|
const LLSD::Binary& weights = mdl[i]["Weights"].asBinary();
|
||||||
|
|
||||||
U32 idx = 0;
|
U32 idx = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -523,7 +523,7 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::
|
||||||
bas >> std::noskipws;
|
bas >> std::noskipws;
|
||||||
data.assign(std::istream_iterator<U8>(bas), std::istream_iterator<U8>());
|
data.assign(std::istream_iterator<U8>(bas), std::istream_iterator<U8>());
|
||||||
|
|
||||||
result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = data;
|
result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = std::move(data);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// This is disabled because it's dangerous. See the other case for an
|
// This is disabled because it's dangerous. See the other case for an
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ void LLTemplateMessageDispatcher::dispatch(const std::string& msg_name,
|
||||||
const LLSD& message,
|
const LLSD& message,
|
||||||
LLHTTPNode::ResponsePtr responsep)
|
LLHTTPNode::ResponsePtr responsep)
|
||||||
{
|
{
|
||||||
std::vector<U8> data = message["body"]["binary-template-data"].asBinary();
|
const LLSD::Binary& data = message["body"]["binary-template-data"].asBinary();
|
||||||
auto size = data.size();
|
auto size = data.size();
|
||||||
if(size == 0)
|
if(size == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -53,11 +53,11 @@ void LLTemplateMessageDispatcher::dispatch(const std::string& msg_name,
|
||||||
LLHost host;
|
LLHost host;
|
||||||
host = gMessageSystem->getSender();
|
host = gMessageSystem->getSender();
|
||||||
|
|
||||||
bool validate_message = mTemplateMessageReader.validateMessage(&(data[0]), static_cast<S32>(size), host, true);
|
bool validate_message = mTemplateMessageReader.validateMessage(data.data(), static_cast<S32>(size), host, true);
|
||||||
|
|
||||||
if (validate_message)
|
if (validate_message)
|
||||||
{
|
{
|
||||||
mTemplateMessageReader.readMessage(&(data[0]),host);
|
mTemplateMessageReader.readMessage(data.data(),host);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ LLSD LLMaterialID::asLLSD() const
|
||||||
materialIDBinary.resize(MATERIAL_ID_SIZE * sizeof(U8));
|
materialIDBinary.resize(MATERIAL_ID_SIZE * sizeof(U8));
|
||||||
memcpy(materialIDBinary.data(), mID, MATERIAL_ID_SIZE * sizeof(U8));
|
memcpy(materialIDBinary.data(), mID, MATERIAL_ID_SIZE * sizeof(U8));
|
||||||
|
|
||||||
LLSD materialID = materialIDBinary;
|
LLSD materialID = std::move(materialIDBinary);
|
||||||
return materialID;
|
return materialID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue