diff options
| author | Rye <rye@alchemyviewer.org> | 2025-12-31 13:07:22 -0500 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2026-01-07 02:15:43 +0200 |
| commit | e440c0e47958ae9adeb775de6a4f033010b82414 (patch) | |
| tree | e9eaa3ca811501a012b22443fc8a37673a52044f /indra/llcommon/lluuid.cpp | |
| parent | 25dc8660efedecfd9f021142ac1e4ff3639e80d4 (diff) | |
Reduce temporary allocations and repeated utf8->utf16 in LLTextureCache with new LLFile IO code
Add non-allocating to_chars and to_wchars string creation functions to LLUUID
Signed-off-by: Rye <rye@alchemyviewer.org>
Diffstat (limited to 'indra/llcommon/lluuid.cpp')
| -rw-r--r-- | indra/llcommon/lluuid.cpp | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index 4aae90626e..867744a29d 100644 --- a/indra/llcommon/lluuid.cpp +++ b/indra/llcommon/lluuid.cpp @@ -151,6 +151,48 @@ U32 janky_fast_random_seeded_bytes(U32 seed, U32 val) } #endif +void LLUUID::to_chars(char* out) const +{ + snprintf(out, UUID_STR_LENGTH, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + (U8)(mData[0]), + (U8)(mData[1]), + (U8)(mData[2]), + (U8)(mData[3]), + (U8)(mData[4]), + (U8)(mData[5]), + (U8)(mData[6]), + (U8)(mData[7]), + (U8)(mData[8]), + (U8)(mData[9]), + (U8)(mData[10]), + (U8)(mData[11]), + (U8)(mData[12]), + (U8)(mData[13]), + (U8)(mData[14]), + (U8)(mData[15])); +} + +void LLUUID::to_wchars(wchar_t* out) const +{ + swprintf(out, UUID_STR_LENGTH, L"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + (U8)(mData[0]), + (U8)(mData[1]), + (U8)(mData[2]), + (U8)(mData[3]), + (U8)(mData[4]), + (U8)(mData[5]), + (U8)(mData[6]), + (U8)(mData[7]), + (U8)(mData[8]), + (U8)(mData[9]), + (U8)(mData[10]), + (U8)(mData[11]), + (U8)(mData[12]), + (U8)(mData[13]), + (U8)(mData[14]), + (U8)(mData[15])); +} + // Common to all UUID implementations void LLUUID::toString(std::string& out) const { @@ -405,8 +447,8 @@ LLUUID LLUUID::combine(const LLUUID& other) const std::ostream& operator<<(std::ostream& s, const LLUUID& uuid) { - std::string uuid_str; - uuid.toString(uuid_str); + char uuid_str[UUID_STR_LENGTH]; + uuid.to_chars(uuid_str); s << uuid_str; return s; } |
