From 80f72fd35e7a84542750b4607e4c1c111451981a Mon Sep 17 00:00:00 2001 From: m910q Date: Thu, 6 Jan 2022 22:10:52 +0100 Subject: [PATCH] Fix for Debug.WriteLine() - Avoid potential String reallocation Debug.WriteLine() no longer reallocate its scoped String when appending a newline. This only happened when the StringView length matches the buffersize in the String. --- BeefLibs/corlib/src/Diagnostics/Debug.bf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BeefLibs/corlib/src/Diagnostics/Debug.bf b/BeefLibs/corlib/src/Diagnostics/Debug.bf index 7ab33151..dd22b0ab 100644 --- a/BeefLibs/corlib/src/Diagnostics/Debug.bf +++ b/BeefLibs/corlib/src/Diagnostics/Debug.bf @@ -70,7 +70,7 @@ namespace System.Diagnostics public static void WriteLine(StringView line) { - String lineStr = scope String(Math.Min(line.Length, 4096)); + String lineStr = scope String(Math.Min(line.Length + 1, 4096)); lineStr.Append(line); lineStr.Append('\n'); Write(lineStr.Ptr, lineStr.Length);