mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Handle nullptr/Span.Empty handling, add explicit overload for ImU8String.AppendFormatted(object)
This commit is contained in:
parent
4dcc81bdfc
commit
ebe184b10c
1 changed files with 19 additions and 1 deletions
|
|
@ -35,7 +35,7 @@ public ref struct ImU8String : IDisposable
|
|||
}
|
||||
|
||||
public ImU8String(int literalLength, int formattedCount)
|
||||
: this(ReadOnlySpan<byte>.Empty)
|
||||
: this(""u8)
|
||||
{
|
||||
this.state |= State.Interpolation;
|
||||
literalLength += formattedCount * 4;
|
||||
|
|
@ -51,6 +51,12 @@ public ref struct ImU8String : IDisposable
|
|||
public ImU8String(ReadOnlySpan<byte> text, bool ensureNullTermination = false)
|
||||
: this()
|
||||
{
|
||||
if (Unsafe.IsNullRef(in MemoryMarshal.GetReference(text)))
|
||||
{
|
||||
this.state = State.None;
|
||||
return;
|
||||
}
|
||||
|
||||
this.state = State.Initialized;
|
||||
if (text.IsEmpty)
|
||||
{
|
||||
|
|
@ -82,6 +88,12 @@ public ref struct ImU8String : IDisposable
|
|||
public ImU8String(ReadOnlySpan<char> text)
|
||||
: this()
|
||||
{
|
||||
if (Unsafe.IsNullRef(in MemoryMarshal.GetReference(text)))
|
||||
{
|
||||
this.state = State.None;
|
||||
return;
|
||||
}
|
||||
|
||||
this.state = State.Initialized | State.NullTerminated;
|
||||
this.Length = Encoding.UTF8.GetByteCount(text);
|
||||
if (this.Length + 1 < AllocFreeBufferSize)
|
||||
|
|
@ -313,6 +325,12 @@ public ref struct ImU8String : IDisposable
|
|||
FixAlignment(startingPos, alignment);
|
||||
}
|
||||
|
||||
public void AppendFormatted(object? value) => this.AppendFormatted<object>(value!);
|
||||
public void AppendFormatted(object? value, string? format) => this.AppendFormatted<object>(value!, format);
|
||||
public void AppendFormatted(object? value, int alignment) => this.AppendFormatted<object>(value!, alignment);
|
||||
public void AppendFormatted(object? value, int alignment, string? format) =>
|
||||
this.AppendFormatted<object>(value!, alignment, format);
|
||||
|
||||
public void AppendFormatted<T>(T value) => this.AppendFormatted(value, null);
|
||||
|
||||
public void AppendFormatted<T>(T value, string? format)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue