Skip to content

Commit bb60b05

Browse files
committed
Merge pull request #104182 from Ivorforce/small-little-string-function
Add missing `String + char *` function, to avoid unnecessary right side allocation to `String`.
2 parents 06f0c63 + 8c14766 commit bb60b05

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

core/string/ustring.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,24 @@ String String::operator+(const String &p_str) const {
365365
return res;
366366
}
367367

368+
String String::operator+(const char *p_str) const {
369+
String res = *this;
370+
res += p_str;
371+
return res;
372+
}
373+
374+
String String::operator+(const wchar_t *p_str) const {
375+
String res = *this;
376+
res += p_str;
377+
return res;
378+
}
379+
380+
String String::operator+(const char32_t *p_str) const {
381+
String res = *this;
382+
res += p_str;
383+
return res;
384+
}
385+
368386
String String::operator+(char32_t p_char) const {
369387
String res = *this;
370388
res += p_char;

core/string/ustring.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ class String {
330330
bool operator==(const String &p_str) const;
331331
bool operator!=(const String &p_str) const;
332332
String operator+(const String &p_str) const;
333+
String operator+(const char *p_char) const;
334+
String operator+(const wchar_t *p_char) const;
335+
String operator+(const char32_t *p_char) const;
333336
String operator+(char32_t p_char) const;
334337

335338
String &operator+=(const String &);

0 commit comments

Comments
 (0)