summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRye Mutt <rye@alchemyviewer.org>2024-07-01 22:35:34 -0400
committerRye Mutt <rye@alchemyviewer.org>2024-07-01 22:35:34 -0400
commit0460d9a5e84599316e505ae25b3f9a8148adb3fa (patch)
tree697d5d97ef5e1de86c1b35e5749dc4cf60691edd /indra
parentb0e30477e93bb16b0cf8c7b64aaee35cedf85ca8 (diff)
Reduce string temporaries from finding colors in the color table
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/llui.cpp2
-rw-r--r--indra/llui/lluicolortable.cpp10
-rw-r--r--indra/llui/lluicolortable.h10
3 files changed, 11 insertions, 11 deletions
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 448c730688..e3ddd66b58 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -529,7 +529,7 @@ namespace LLInitParam
{
if (control.isProvided() && !control().empty())
{
- updateValue(LLUIColorTable::instance().getColor(control));
+ updateValue(LLUIColorTable::instance().getColor(control()));
}
else
{
diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp
index 54f8727fa5..3279926786 100644
--- a/indra/llui/lluicolortable.cpp
+++ b/indra/llui/lluicolortable.cpp
@@ -63,7 +63,7 @@ void LLUIColorTable::insertFromParams(const Params& p, string_color_map_t& table
ColorEntryParams color_entry = *it;
if(color_entry.color.value.isChosen())
{
- setColor(color_entry.name, color_entry.color.value, table);
+ setColor(color_entry.name(), color_entry.color.value, table);
}
else
{
@@ -176,7 +176,7 @@ void LLUIColorTable::clear()
clearTable(mUserSetColors);
}
-LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& default_color) const
+LLUIColor LLUIColorTable::getColor(std::string_view name, const LLColor4& default_color) const
{
string_color_map_t::const_iterator iter = mUserSetColors.find(name);
@@ -196,7 +196,7 @@ LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& defa
}
// update user color, loaded colors are parsed on initialization
-void LLUIColorTable::setColor(const std::string& name, const LLColor4& color)
+void LLUIColorTable::setColor(std::string_view name, const LLColor4& color)
{
setColor(name, color, mUserSetColors);
}
@@ -258,7 +258,7 @@ void LLUIColorTable::saveUserSettings() const
}
}
-bool LLUIColorTable::colorExists(const std::string& color_name) const
+bool LLUIColorTable::colorExists(std::string_view color_name) const
{
return ((mLoadedColors.find(color_name) != mLoadedColors.end())
|| (mUserSetColors.find(color_name) != mUserSetColors.end()));
@@ -276,7 +276,7 @@ void LLUIColorTable::clearTable(string_color_map_t& table)
// this method inserts a color into the table if it does not exist
// if the color already exists it changes the color
-void LLUIColorTable::setColor(const std::string& name, const LLColor4& color, string_color_map_t& table)
+void LLUIColorTable::setColor(std::string_view name, const LLColor4& color, string_color_map_t& table)
{
string_color_map_t::iterator it = table.lower_bound(name);
if(it != table.end()
diff --git a/indra/llui/lluicolortable.h b/indra/llui/lluicolortable.h
index 7232077cab..ca1ca9eaa7 100644
--- a/indra/llui/lluicolortable.h
+++ b/indra/llui/lluicolortable.h
@@ -42,7 +42,7 @@ class LLUIColorTable : public LLSingleton<LLUIColorTable>
LOG_CLASS(LLUIColorTable);
// consider using sorted vector, can be much faster
- typedef std::map<std::string, LLUIColor> string_color_map_t;
+ typedef std::map<std::string, LLUIColor, std::less<>> string_color_map_t;
public:
struct ColorParams : LLInitParam::ChoiceBlock<ColorParams>
@@ -75,13 +75,13 @@ public:
void clear();
// color lookup
- LLUIColor getColor(const std::string& name, const LLColor4& default_color = LLColor4::magenta) const;
+ LLUIColor getColor(std::string_view name, const LLColor4& default_color = LLColor4::magenta) const;
// if the color is in the table, it's value is changed, otherwise it is added
- void setColor(const std::string& name, const LLColor4& color);
+ void setColor(std::string_view name, const LLColor4& color);
// returns true if color_name exists in the table
- bool colorExists(const std::string& color_name) const;
+ bool colorExists(std::string_view color_name) const;
// loads colors from settings files
bool loadFromSettings();
@@ -95,7 +95,7 @@ private:
void insertFromParams(const Params& p, string_color_map_t& table);
void clearTable(string_color_map_t& table);
- void setColor(const std::string& name, const LLColor4& color, string_color_map_t& table);
+ void setColor(std::string_view name, const LLColor4& color, string_color_map_t& table);
string_color_map_t mLoadedColors;
string_color_map_t mUserSetColors;