diff options
author | vnugent <public@vaughnnugent.com> | 2024-06-13 21:57:34 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-06-13 21:57:34 -0400 |
commit | 7d2987f1d4048c30808a85798e32c99747f6cfe3 (patch) | |
tree | a1d1ecc8e479a12abbe7cfa637b584101ecee27d /lib/Utils | |
parent | 75c1d0cbf9a5a7856c544671a45f1b4312ffe7ce (diff) |
perf: Async pre-buffer to avoid sync buffer
Diffstat (limited to 'lib/Utils')
-rw-r--r-- | lib/Utils/src/IO/IVnTextReader.cs | 7 | ||||
-rw-r--r-- | lib/Utils/src/IO/VnTextReaderExtensions.cs | 4 | ||||
-rw-r--r-- | lib/Utils/src/Memory/MemoryUtil.cs | 6 |
3 files changed, 8 insertions, 9 deletions
diff --git a/lib/Utils/src/IO/IVnTextReader.cs b/lib/Utils/src/IO/IVnTextReader.cs index 625ba78..93de2d1 100644 --- a/lib/Utils/src/IO/IVnTextReader.cs +++ b/lib/Utils/src/IO/IVnTextReader.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Utils @@ -23,7 +23,6 @@ */ using System; -using System.IO; using System.Text; namespace VNLib.Utils.IO @@ -34,10 +33,6 @@ namespace VNLib.Utils.IO public interface IVnTextReader { /// <summary> - /// The base stream to read data from - /// </summary> - Stream BaseStream { get; } - /// <summary> /// The character encoding used by the TextReader /// </summary> Encoding Encoding { get; } diff --git a/lib/Utils/src/IO/VnTextReaderExtensions.cs b/lib/Utils/src/IO/VnTextReaderExtensions.cs index 9ca5ae5..5dc6117 100644 --- a/lib/Utils/src/IO/VnTextReaderExtensions.cs +++ b/lib/Utils/src/IO/VnTextReaderExtensions.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Utils @@ -66,6 +66,7 @@ namespace VNLib.Utils.IO /// <remarks>Allows reading lines of data from the stream without allocations</remarks> public static ERRNO ReadLine<T>(this T reader, Span<char> charBuffer) where T : class, IVnTextReader { + ArgumentNullException.ThrowIfNull(reader); return ReadLineInternal(ref reader, charBuffer); } @@ -118,6 +119,7 @@ namespace VNLib.Utils.IO /// <remarks>You should use the <see cref="IVnTextReader.Available"/> property to know how much remaining data is buffered</remarks> public static int ReadRemaining<T>(this T reader, Span<byte> buffer) where T : class, IVnTextReader { + ArgumentNullException.ThrowIfNull(reader); return ReadRemainingInternal(ref reader, buffer); } diff --git a/lib/Utils/src/Memory/MemoryUtil.cs b/lib/Utils/src/Memory/MemoryUtil.cs index 7ce7c81..d10efc8 100644 --- a/lib/Utils/src/Memory/MemoryUtil.cs +++ b/lib/Utils/src/Memory/MemoryUtil.cs @@ -964,7 +964,8 @@ namespace VNLib.Utils.Memory /// <summary> /// Optimized memmove for known small memory blocks. This method is faster than /// <see cref="Memmove{T}(ref readonly T, nuint, ref T, nuint, nuint)"/> when the - /// number of elements to copy is known to be small. + /// number of elements to copy is known to be small. Pointers to src and dst may be + /// overlapping regions of memory. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="src">A readonly reference to the first element in the source memory sequence</param> @@ -999,7 +1000,7 @@ namespace VNLib.Utils.Memory /// <summary> /// Low level api for copying data from source memory to destination memory of an - /// umanged data type. + /// umanged data type. Pointers to src and dst may be overlapping regions of memory. /// </summary> /// <remarks> /// WARNING: It's not possible to do bounds checking when using references. Be sure you @@ -1034,6 +1035,7 @@ namespace VNLib.Utils.Memory /// <summary> /// Low level api for copying data from source memory to destination memory of an /// umanged data type. This call attempts to force hadrware acceleration if supported. + /// Pointers to src and dst may be overlapping regions of memory. /// <para> /// Understand that using this function attempts to force hardware acceleration, which /// may hurt performance if the data is not large enough to justify the overhead. |