From 8c14766597803b410bd5ea3d72660ab6265baa95 Mon Sep 17 00:00:00 2001 From: Lukas Tenbrink Date: Sat, 15 Mar 2025 16:55:49 +0100 Subject: [PATCH] Add missing `String + char *` function, to avoid unnecessary right side allocation to `String`. --- core/string/ustring.cpp | 18 ++++++++++++++++++ core/string/ustring.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 3608d1afc16..9754bef5ad5 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -365,6 +365,24 @@ String String::operator+(const String &p_str) const { return res; } +String String::operator+(const char *p_str) const { + String res = *this; + res += p_str; + return res; +} + +String String::operator+(const wchar_t *p_str) const { + String res = *this; + res += p_str; + return res; +} + +String String::operator+(const char32_t *p_str) const { + String res = *this; + res += p_str; + return res; +} + String String::operator+(char32_t p_char) const { String res = *this; res += p_char; diff --git a/core/string/ustring.h b/core/string/ustring.h index fdac0d5d68c..6fe5e3d7088 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -330,6 +330,9 @@ public: bool operator==(const String &p_str) const; bool operator!=(const String &p_str) const; String operator+(const String &p_str) const; + String operator+(const char *p_char) const; + String operator+(const wchar_t *p_char) const; + String operator+(const char32_t *p_char) const; String operator+(char32_t p_char) const; String &operator+=(const String &);