Skip to content
Snippets Groups Projects
Commit c237f319 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Reduce string temporaries during LLSD insertion

parent f5e2acb6
No related branches found
No related tags found
No related merge requests found
...@@ -152,7 +152,7 @@ class LLSD::Impl ...@@ -152,7 +152,7 @@ class LLSD::Impl
virtual bool has(const std::string_view) const { return false; } virtual bool has(const std::string_view) const { return false; }
virtual LLSD get(const std::string_view) const { return LLSD(); } virtual LLSD get(const std::string_view) const { return LLSD(); }
virtual LLSD getKeys() const { return LLSD::emptyArray(); } 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 const LLSD& ref(const std::string_view) const{ return undef(); }
virtual size_t size() const { return 0; } virtual size_t size() const { return 0; }
...@@ -403,9 +403,9 @@ namespace ...@@ -403,9 +403,9 @@ namespace
using LLSD::Impl::ref; // Unhiding ref(size_t) using LLSD::Impl::ref; // Unhiding ref(size_t)
LLSD get(const std::string_view) const override; LLSD get(const std::string_view) const override;
LLSD getKeys() const override; LLSD getKeys() const override;
void insert(const LLSD::String& k, const LLSD& v); void insert(const std::string_view k, const LLSD& v);
void erase(const LLSD::String&) override; void erase(const std::string_view) override;
LLSD& ref(const std::string_view); LLSD& ref(const std::string_view);
const LLSD& ref(const std::string_view) const override; const LLSD& ref(const std::string_view) const override;
size_t size() const override { return mData.size(); } size_t size() const override { return mData.size(); }
...@@ -461,13 +461,13 @@ namespace ...@@ -461,13 +461,13 @@ namespace
return keys; 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; 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; LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
mData.erase(k); mData.erase(k);
...@@ -944,14 +944,14 @@ LLSD LLSD::emptyMap() ...@@ -944,14 +944,14 @@ LLSD LLSD::emptyMap()
bool LLSD::has(const std::string_view k) const { return safe(impl).has(k); } 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::get(const std::string_view k) const { return safe(impl).get(k); }
LLSD LLSD::getKeys() const { return safe(impl).getKeys(); } 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); makeMap(impl).insert(k, v);
return *this; 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) LLSD& LLSD::operator[](const std::string_view k)
{ {
......
...@@ -330,9 +330,9 @@ class LL_COMMON_API LLSD final ...@@ -330,9 +330,9 @@ class LL_COMMON_API LLSD final
bool has(const std::string_view) const; bool has(const std::string_view) const;
LLSD get(const std::string_view) const; LLSD get(const std::string_view) const;
LLSD getKeys() const; // Return an LLSD array with keys as strings LLSD getKeys() const; // Return an LLSD array with keys as strings
void insert(const String&, const LLSD&); void insert(const std::string_view, const LLSD&);
void erase(const String&); void erase(const std::string_view);
LLSD& with(const String&, const LLSD&); LLSD& with(const std::string_view, const LLSD&);
LLSD& operator[](const std::string_view); LLSD& operator[](const std::string_view);
LLSD& operator[](const char* c) { return (*this)[al::safe_string_view(c)]; } LLSD& operator[](const char* c) { return (*this)[al::safe_string_view(c)]; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment