From 8b33efd31b082a78c9f6a71da17439176ae33db9 Mon Sep 17 00:00:00 2001 From: Vitalii Mikhailov Date: Sat, 12 Oct 2024 15:13:15 +0300 Subject: [PATCH] Fixed padding --- .../ImGui/CmGui.Methods.cs | 12 +++++------- src/BUTR.CrashReport.Renderer.ImGui/ImGui/CmGui.cs | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/BUTR.CrashReport.Renderer.ImGui/ImGui/CmGui.Methods.cs b/src/BUTR.CrashReport.Renderer.ImGui/ImGui/CmGui.Methods.cs index 0d6bf18..0f687c8 100644 --- a/src/BUTR.CrashReport.Renderer.ImGui/ImGui/CmGui.Methods.cs +++ b/src/BUTR.CrashReport.Renderer.ImGui/ImGui/CmGui.Methods.cs @@ -87,13 +87,11 @@ public void TextSameLine(ReadOnlySpan fmt) [MethodImpl(MethodImplOptions.AggressiveInlining | AggressiveOptimization)] public void PadRight(int toAppend) { - fixed (byte* paddingPtr = _padding) - { - var offset = _padding.Length - toAppend; - var paddingPtrWithOffset = (byte*) Unsafe.Add(paddingPtr, offset); - igText(paddingPtrWithOffset); - SameLine(0, 0); - } + Span padding = stackalloc byte[toAppend + 1]; + padding.Fill((byte) ' '); + padding[toAppend] = 0; + Text(padding); + SameLine(0, 0); } public void TextSameLine(ref readonly byte fmt) { diff --git a/src/BUTR.CrashReport.Renderer.ImGui/ImGui/CmGui.cs b/src/BUTR.CrashReport.Renderer.ImGui/ImGui/CmGui.cs index 89abfdd..f816b7e 100644 --- a/src/BUTR.CrashReport.Renderer.ImGui/ImGui/CmGui.cs +++ b/src/BUTR.CrashReport.Renderer.ImGui/ImGui/CmGui.cs @@ -9,7 +9,6 @@ internal partial class CmGui { private const MethodImplOptions AggressiveOptimization = (MethodImplOptions) 512; - private static readonly byte[] _padding = UnsafeHelper.ToUtf8Array(string.Empty.PadRight(64)); private static readonly Vector2 Zero2 = Vector2.Zero; private static readonly Vector3 Zero3 = Vector3.Zero; private static readonly Vector4 Zero4 = Vector4.Zero;