summaryrefslogtreecommitdiff
path: root/indra/llcommon/llsd.h
diff options
context:
space:
mode:
authorRye Mutt <rye@alchemyviewer.org>2024-07-03 17:32:45 -0400
committerRye Mutt <rye@alchemyviewer.org>2024-07-05 02:56:24 -0400
commit59312bf209c5fcdb27c283caaa2ed36502ec7a33 (patch)
tree1288037eb250a24d23de8d388e8511f5999ddf62 /indra/llcommon/llsd.h
parentb099dbef27f2af47a421bb9848cfbca1aaa08327 (diff)
Introduce string_view to LLSD map functions to reduce string temporaries
Diffstat (limited to 'indra/llcommon/llsd.h')
-rw-r--r--indra/llcommon/llsd.h28
1 files changed, 13 insertions, 15 deletions
diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h
index 5532decfc3..675cbb0edb 100644
--- a/indra/llcommon/llsd.h
+++ b/indra/llcommon/llsd.h
@@ -306,25 +306,23 @@ public:
//@{
static LLSD emptyMap();
- bool has(const String&) const;
- LLSD get(const String&) const;
+ 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 insert(std::string_view, const LLSD&);
void erase(const String&);
- LLSD& with(const String&, const LLSD&);
+ LLSD& with(std::string_view, const LLSD&);
- LLSD& operator[](const String&);
+ LLSD& operator[](const std::string_view);
LLSD& operator[](const char* c)
- {
- LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
- return (*this)[String(c)];
- }
- const LLSD& operator[](const String&) const;
- const LLSD& operator[](const char* c) const
- {
- LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
- return (*this)[String(c)];
- }
+ {
+ return c ? (*this)[std::string_view(c)] : *this;
+ }
+ const LLSD& operator[](const std::string_view) const;
+ const LLSD& operator[](const char* c) const
+ {
+ return c ? (*this)[std::string_view(c)] : *this;
+ }
//@}
/** @name Array Values */