From dc119c178f5c920518946ae22ea6fc97e266c139 Mon Sep 17 00:00:00 2001 From: gibbed Date: Mon, 13 Apr 2020 10:29:04 -0500 Subject: [PATCH] [Base] Add repeating character append to StringBuffer. --- src/xenia/base/string_buffer.cc | 7 +++++++ src/xenia/base/string_buffer.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/xenia/base/string_buffer.cc b/src/xenia/base/string_buffer.cc index 90d386f23..050ddf9d8 100644 --- a/src/xenia/base/string_buffer.cc +++ b/src/xenia/base/string_buffer.cc @@ -52,6 +52,13 @@ void StringBuffer::Append(char c) { AppendBytes(reinterpret_cast(&c), 1); } +void StringBuffer::Append(char c, size_t count) { + Grow(count + 1); + std::memset(buffer_ + buffer_offset_, c, count); + buffer_offset_ += count; + buffer_[buffer_offset_] = 0; +} + void StringBuffer::Append(const char* value) { AppendBytes(reinterpret_cast(value), std::strlen(value)); } diff --git a/src/xenia/base/string_buffer.h b/src/xenia/base/string_buffer.h index bd6063fe4..16900824a 100644 --- a/src/xenia/base/string_buffer.h +++ b/src/xenia/base/string_buffer.h @@ -29,6 +29,7 @@ class StringBuffer { void Reset(); void Append(char c); + void Append(char c, size_t count); void Append(const char* value); void Append(const std::string_view value);