mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Use custom GetPinnableReference instead of deferring it to Span (#2345)
This commit is contained in:
parent
2cd5c5bc68
commit
3e40cad063
9 changed files with 107 additions and 52 deletions
|
|
@ -169,6 +169,28 @@ public ref struct ImU8String : IDisposable
|
|||
public static unsafe implicit operator ImU8String(byte* text) => new(text);
|
||||
public static unsafe implicit operator ImU8String(char* text) => new(text);
|
||||
|
||||
public ref readonly byte GetPinnableReference()
|
||||
{
|
||||
if (this.IsNull)
|
||||
return ref Unsafe.NullRef<byte>();
|
||||
|
||||
if (this.IsEmpty)
|
||||
return ref this.FixedBufferSpan[0];
|
||||
|
||||
return ref this.Span.GetPinnableReference();
|
||||
}
|
||||
|
||||
public ref readonly byte GetPinnableReference(ReadOnlySpan<byte> defaultValue)
|
||||
{
|
||||
if (this.IsNull)
|
||||
return ref defaultValue.GetPinnableReference();
|
||||
|
||||
if (this.IsEmpty)
|
||||
return ref this.FixedBufferSpan[0];
|
||||
|
||||
return ref this.Span.GetPinnableReference();
|
||||
}
|
||||
|
||||
public ref readonly byte GetPinnableNullTerminatedReference(ReadOnlySpan<byte> defaultValue = default)
|
||||
{
|
||||
if (this.IsNull)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue