diff options
Diffstat (limited to 'source/core/slang-string.cpp')
| -rw-r--r-- | source/core/slang-string.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp index b195e12d5..648249b2c 100644 --- a/source/core/slang-string.cpp +++ b/source/core/slang-string.cpp @@ -253,7 +253,31 @@ namespace Slang ensureUniqueStorageWithCapacity(newLength); return getData() + oldLength; } + void String::appendInPlace(const char* chars, UInt count) + { + SLANG_UNUSED(chars); + + if (count > 0) + { + SLANG_ASSERT(buffer && buffer->isUniquelyReferenced()); + + auto oldLength = getLength(); + auto newLength = oldLength + count; + + char* dst = buffer->getData(); + // Make sure the input buffer is the same one returned from prepareForAppend + SLANG_ASSERT(chars == dst + oldLength); + // It has to fit within the capacity + SLANG_ASSERT(newLength <= buffer->capacity); + + // We just need to modify the length + buffer->length = newLength; + + // And mark with a terminating 0 + dst[newLength] = 0; + } + } void String::append(const char* textBegin, char const* textEnd) { |
