From 33a34fe670176490852ffc96370e89146db0c315 Mon Sep 17 00:00:00 2001 From: Lukas Tenbrink Date: Thu, 9 Jan 2025 17:13:06 +0100 Subject: [PATCH] Inline `String::utf8` and `String::utf16` for their simplicity. --- core/string/ustring.cpp | 14 -------------- core/string/ustring.h | 12 ++++++++++-- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 48d900d1969..4c76b1e605f 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -1954,13 +1954,6 @@ CharString String::ascii(bool p_allow_extended) const { return cs; } -String String::utf8(const char *p_utf8, int p_len) { - String ret; - ret.parse_utf8(p_utf8, p_len); - - return ret; -} - Error String::parse_utf8(const char *p_utf8, int p_len, bool p_skip_cr) { if (!p_utf8) { return ERR_INVALID_DATA; @@ -2225,13 +2218,6 @@ CharString String::utf8() const { return utf8s; } -String String::utf16(const char16_t *p_utf16, int p_len) { - String ret; - ret.parse_utf16(p_utf16, p_len, true); - - return ret; -} - Error String::parse_utf16(const char16_t *p_utf16, int p_len, bool p_default_little_endian) { if (!p_utf16) { return ERR_INVALID_DATA; diff --git a/core/string/ustring.h b/core/string/ustring.h index b8ebeb99d7c..4e329261f8a 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -523,11 +523,19 @@ public: CharString ascii(bool p_allow_extended = false) const; CharString utf8() const; Error parse_utf8(const char *p_utf8, int p_len = -1, bool p_skip_cr = false); - static String utf8(const char *p_utf8, int p_len = -1); + static String utf8(const char *p_utf8, int p_len = -1) { + String ret; + ret.parse_utf8(p_utf8, p_len); + return ret; + } Char16String utf16() const; Error parse_utf16(const char16_t *p_utf16, int p_len = -1, bool p_default_little_endian = true); - static String utf16(const char16_t *p_utf16, int p_len = -1); + static String utf16(const char16_t *p_utf16, int p_len = -1) { + String ret; + ret.parse_utf16(p_utf16, p_len, true); + return ret; + } static uint32_t hash(const char32_t *p_cstr, int p_len); /* hash the string */ static uint32_t hash(const char32_t *p_cstr); /* hash the string */