diff options
author | vnugent <public@vaughnnugent.com> | 2024-09-23 21:54:21 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-09-23 21:54:21 -0400 |
commit | 8da9685d9bf3fcd73a775cb7306e4e188cfa214b (patch) | |
tree | c7477e48170aa563ddcbec11dafefa1611397199 /lib/Utils/src | |
parent | dd9d2aa0a1db1486ed35716e49d006db9c1f55b0 (diff) |
feat: scoped spans for forward writer & tests to sln
Diffstat (limited to 'lib/Utils/src')
-rw-r--r-- | lib/Utils/src/Memory/ForwardOnlyWriter.cs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/Utils/src/Memory/ForwardOnlyWriter.cs b/lib/Utils/src/Memory/ForwardOnlyWriter.cs index 55e3b11..947ae18 100644 --- a/lib/Utils/src/Memory/ForwardOnlyWriter.cs +++ b/lib/Utils/src/Memory/ForwardOnlyWriter.cs @@ -82,7 +82,7 @@ namespace VNLib.Utils.Memory /// </summary> /// <param name="data">The data sequence to append to the buffer</param> /// <exception cref="ArgumentOutOfRangeException"></exception> - public void Append<TClass>(ReadOnlySpan<T> data) where TClass : class, T + public void Append<TClass>(scoped ReadOnlySpan<T> data) where TClass : class, T { //Make sure the current window is large enough to buffer the new string ArgumentOutOfRangeException.ThrowIfGreaterThan(data.Length, RemainingSize, nameof(Remaining)); @@ -101,18 +101,18 @@ namespace VNLib.Utils.Memory /// <typeparam name="TStruct"></typeparam> /// <param name="data">The data sequence to append to the buffer</param> /// <exception cref="ArgumentOutOfRangeException"></exception> - public void Append<TStruct>(ReadOnlySpan<TStruct> data) where TStruct : struct, T + public void Append<TStruct>(scoped ReadOnlySpan<TStruct> data) where TStruct : struct, T { //Make sure the current window is large enough to buffer the new string ArgumentOutOfRangeException.ThrowIfGreaterThan(data.Length, RemainingSize, nameof(Remaining)); //write data to window MemoryUtil.Memmove( - in MemoryMarshal.GetReference(data), - 0, - ref Unsafe.As<T, TStruct>(ref _basePtr), //Reinterpret the ref to the local scope type, - (nuint)Written, - (nuint)data.Length + src: in MemoryMarshal.GetReference(data), + srcOffset: 0, + dst: ref Unsafe.As<T, TStruct>(ref _basePtr), //Reinterpret the ref to the local scope type, + dstOffset: (nuint)Written, + elementCount: (nuint)data.Length ); //update char position @@ -127,18 +127,18 @@ namespace VNLib.Utils.Memory /// <typeparam name="TStruct"></typeparam> /// <param name="data">The data sequence to append to the buffer</param> /// <exception cref="ArgumentOutOfRangeException"></exception> - public void AppendSmall<TStruct>(ReadOnlySpan<TStruct> data) where TStruct : struct, T + public void AppendSmall<TStruct>(scoped ReadOnlySpan<TStruct> data) where TStruct : struct, T { //Make sure the current window is large enough to buffer the new string ArgumentOutOfRangeException.ThrowIfGreaterThan(data.Length, RemainingSize, nameof(Remaining)); //write data to window MemoryUtil.SmallMemmove( - in MemoryMarshal.GetReference(data), - 0, - ref Unsafe.As<T, TStruct>(ref _basePtr), //Reinterpret the ref to the local scope type, - (nuint)Written, - (ushort)data.Length + src: in MemoryMarshal.GetReference(data), + srcOffset: 0, + dst: ref Unsafe.As<T, TStruct>(ref _basePtr), //Reinterpret the ref to the local scope type, + dstOffset: (nuint)Written, + elementCount: (ushort)data.Length ); //update char position |