diff options
Diffstat (limited to 'source/core/slang-string.cpp')
| -rw-r--r-- | source/core/slang-string.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp index 6d06eb1c6..4b1ec4c84 100644 --- a/source/core/slang-string.cpp +++ b/source/core/slang-string.cpp @@ -362,15 +362,25 @@ namespace Slang } } - void String::append(char chr) + void String::appendChar(char c) { - append(&chr, &chr + 1); - } + const auto oldLength = getLength(); + const auto newLength = oldLength + 1; + + ensureUniqueStorageWithCapacity(newLength); + // Since there must be space for at least one character, m_buffer cannot be nullptr + SLANG_ASSERT(m_buffer); + char* data = m_buffer->getData(); + data[oldLength] = c; + data[newLength] = 0; - void String::appendChar(char chr) + m_buffer->length = newLength; + } + + void String::append(char chr) { - append(&chr, &chr + 1); + appendChar(chr); } void String::append(String const& str) |
