From 80b1af2352270697cf8f84d14bb88c2e84e32801 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 9 Feb 2020 11:47:24 +0100 Subject: [PATCH] AK: Make StringBuilder::to_string() non-destructive This was an artifact of an earlier design of StringBuilder where I had attempted to preserve the same allocation from build to final String. --- AK/StringBuilder.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/AK/StringBuilder.cpp b/AK/StringBuilder.cpp index 619450fcb8..e60f1c8826 100644 --- a/AK/StringBuilder.cpp +++ b/AK/StringBuilder.cpp @@ -93,9 +93,7 @@ ByteBuffer StringBuilder::to_byte_buffer() String StringBuilder::to_string() { - auto string = String((const char*)m_buffer.data(), m_length); - clear(); - return string; + return String((const char*)m_buffer.data(), m_length); } StringView StringBuilder::string_view() const