diff options
author | Hein-Pieter van Braam <hp@tmm.cx> | 2018-12-16 00:44:18 +0000 |
---|---|---|
committer | Hein-Pieter van Braam <hp@tmm.cx> | 2018-12-16 16:51:38 +0100 |
commit | 4e25e5066bfd6a1ea9d5dbfa5db9e25b66b8aa02 (patch) | |
tree | 1d774f8ffe2f6321aa22bfe9148ddc24515ae8ba /core/ustring.cpp | |
parent | 7ac67bfec106d2ae807e845d0e093c6e0f2c43b5 (diff) | |
download | redot-engine-4e25e5066bfd6a1ea9d5dbfa5db9e25b66b8aa02.tar.gz |
Reduce String CoW
By introducing an intermediate proxy class for the array subscript
operator for String and CharString we can control better when CowData
will actually CoW.
This should improve performance of String usage for most cases.
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r-- | core/ustring.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 3f017fa985..083a1eaed6 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -179,7 +179,7 @@ void String::copy_from_unchecked(const CharType *p_char, const int p_length) { resize(p_length + 1); set(p_length, 0); - CharType *dst = &operator[](0); + CharType *dst = ptrw(); for (int i = 0; i < p_length; i++) { dst[i] = p_char[i]; @@ -250,7 +250,7 @@ String &String::operator+=(const String &p_str) { resize(length() + p_str.size()); const CharType *src = p_str.c_str(); - CharType *dst = &operator[](0); + CharType *dst = ptrw(); set(length(), 0); @@ -289,7 +289,7 @@ String &String::operator+=(const char *p_str) { resize(from + src_len + 1); - CharType *dst = &operator[](0); + CharType *dst = ptrw(); set(length(), 0); @@ -1431,7 +1431,7 @@ bool String::parse_utf8(const char *p_utf8, int p_len) { } resize(str_size + 1); - CharType *dst = &operator[](0); + CharType *dst = ptrw(); dst[str_size] = 0; while (cstr_size) { @@ -3476,7 +3476,7 @@ String String::xml_unescape() const { if (len == 0) return String(); str.resize(len + 1); - _xml_unescape(c_str(), l, &str[0]); + _xml_unescape(c_str(), l, str.ptrw()); str[len] = 0; return str; } |