From c237f31913006cb6229ed466bf8bd777ee0c27e0 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Fri, 17 Nov 2023 19:32:12 -0500 Subject: [PATCH] Reduce string temporaries during LLSD insertion --- indra/llcommon/llsd.cpp | 20 ++++++++++---------- indra/llcommon/llsd.h | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index d9d54b89ae1..6b037cc574f 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -152,7 +152,7 @@ class LLSD::Impl virtual bool has(const std::string_view) const { return false; } virtual LLSD get(const std::string_view) const { return LLSD(); } virtual LLSD getKeys() const { return LLSD::emptyArray(); } - virtual void erase(const String&) { } + virtual void erase(std::string_view) { } virtual const LLSD& ref(const std::string_view) const{ return undef(); } virtual size_t size() const { return 0; } @@ -403,9 +403,9 @@ namespace using LLSD::Impl::ref; // Unhiding ref(size_t) LLSD get(const std::string_view) const override; LLSD getKeys() const override; - void insert(const LLSD::String& k, const LLSD& v); - void erase(const LLSD::String&) override; - LLSD& ref(const std::string_view); + void insert(const std::string_view k, const LLSD& v); + void erase(const std::string_view) override; + LLSD& ref(const std::string_view); const LLSD& ref(const std::string_view) const override; size_t size() const override { return mData.size(); } @@ -461,13 +461,13 @@ namespace return keys; } - void ImplMap::insert(const LLSD::String& k, const LLSD& v) + void ImplMap::insert(const std::string_view k, const LLSD& v) { LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; - mData.emplace(DataMap::value_type(k, v)); + mData.emplace(k, v); } - void ImplMap::erase(const LLSD::String& k) + void ImplMap::erase(const std::string_view k) { LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; mData.erase(k); @@ -944,14 +944,14 @@ LLSD LLSD::emptyMap() bool LLSD::has(const std::string_view k) const { return safe(impl).has(k); } LLSD LLSD::get(const std::string_view k) const { return safe(impl).get(k); } LLSD LLSD::getKeys() const { return safe(impl).getKeys(); } -void LLSD::insert(const String& k, const LLSD& v) { makeMap(impl).insert(k, v); } +void LLSD::insert(const std::string_view k, const LLSD& v) { makeMap(impl).insert(k, v); } -LLSD& LLSD::with(const String& k, const LLSD& v) +LLSD& LLSD::with(const std::string_view k, const LLSD& v) { makeMap(impl).insert(k, v); return *this; } -void LLSD::erase(const String& k) { makeMap(impl).erase(k); } +void LLSD::erase(const std::string_view k) { makeMap(impl).erase(k); } LLSD& LLSD::operator[](const std::string_view k) { diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index b1017873e9a..4c2a074c5af 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -330,9 +330,9 @@ class LL_COMMON_API LLSD final bool has(const std::string_view) const; LLSD get(const std::string_view) const; LLSD getKeys() const; // Return an LLSD array with keys as strings - void insert(const String&, const LLSD&); - void erase(const String&); - LLSD& with(const String&, const LLSD&); + void insert(const std::string_view, const LLSD&); + void erase(const std::string_view); + LLSD& with(const std::string_view, const LLSD&); LLSD& operator[](const std::string_view); LLSD& operator[](const char* c) { return (*this)[al::safe_string_view(c)]; } -- GitLab