From 2696b3de088877c3a406e817ed232c252700a16c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 24 May 2024 03:25:28 +0200 Subject: Introduce LLWStringView to prevent unnecessary memory allocations --- indra/llcommon/llstring.cpp | 2 +- indra/llcommon/llstring.h | 3 ++- indra/newview/llfloaterimsessiontab.cpp | 4 ++-- indra/newview/llfloaterimsessiontab.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index bbb6aa2c20..5df0f8702d 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -758,7 +758,7 @@ std::string utf8str_showBytesUTF8(const std::string& utf8str) } // Search for any emoji symbol, return true if found -bool wstring_has_emoji(const LLWString& wstr) +bool wstring_has_emoji(LLWStringView wstr) { for (const llwchar& wch : wstr) { diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 61d698687a..123f4184b5 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -448,6 +448,7 @@ template std::string LLStringUtilBase::sLocale; typedef LLStringUtilBase LLStringUtil; typedef LLStringUtilBase LLWStringUtil; typedef std::basic_string LLWString; +typedef std::basic_string_view LLWStringView; //@ Use this where we want to disallow input in the form of "foo" // This is used to catch places where english text is embedded in the code @@ -749,7 +750,7 @@ LL_COMMON_API llwchar utf8str_to_wchar(const std::string& utf8str, size_t offset LL_COMMON_API std::string utf8str_showBytesUTF8(const std::string& utf8str); -LL_COMMON_API bool wstring_has_emoji(const LLWString& wstr); +LL_COMMON_API bool wstring_has_emoji(LLWStringView wstr); LL_COMMON_API bool wstring_remove_emojis(LLWString& wstr); diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp index 81a4f9936c..a0b56b14f0 100644 --- a/indra/newview/llfloaterimsessiontab.cpp +++ b/indra/newview/llfloaterimsessiontab.cpp @@ -587,13 +587,13 @@ void LLFloaterIMSessionTab::appendMessage(const LLChat& chat, const LLSD& args) mChatHistory->appendMessage(chat, chat_args); } -void LLFloaterIMSessionTab::updateUsedEmojis(LLWString text) +void LLFloaterIMSessionTab::updateUsedEmojis(LLWStringView text) { LLEmojiDictionary* dictionary = LLEmojiDictionary::getInstance(); llassert_always(dictionary); bool emojiSent = false; - for (llwchar& c : text) + for (const llwchar& c : text) { if (dictionary->isEmoji(c)) { diff --git a/indra/newview/llfloaterimsessiontab.h b/indra/newview/llfloaterimsessiontab.h index f1773520af..0a8502cfc5 100644 --- a/indra/newview/llfloaterimsessiontab.h +++ b/indra/newview/llfloaterimsessiontab.h @@ -147,7 +147,7 @@ protected: std::string appendTime(); void assignResizeLimits(); - void updateUsedEmojis(LLWString text); + void updateUsedEmojis(LLWStringView text); S32 mFloaterExtraWidth; -- cgit v1.2.3