Skip to content

Instantly share code, notes, and snippets.

View NoelFB's full-sized avatar

Noel Berry NoelFB

View GitHub Profile
@NoelFB
NoelFB / StackString.cs
Created October 5, 2023 04:43
simple stack-based C# string
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <summary>
/// Stack-based String
/// </summary>
[InterpolatedStringHandler]
[SkipLocalsInit]
public unsafe struct StackString
{
@NoelFB
NoelFB / StackUtf8.cs
Created October 5, 2023 04:45
Stack based UTF8 string in C#
using System.Buffers;
using System.Buffers.Text;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
/// <summary>
/// Stack-based UTF8 string for ImGui.
/// I frequently want to do short string manipulation (ex. $"{Icon} Play!") and this
/// avoids allocating on the new strings every single frame.