From 7d2987f1d4048c30808a85798e32c99747f6cfe3 Mon Sep 17 00:00:00 2001 From: vnugent Date: Thu, 13 Jun 2024 21:57:34 -0400 Subject: perf: Async pre-buffer to avoid sync buffer --- lib/Utils/src/IO/IVnTextReader.cs | 7 +------ lib/Utils/src/IO/VnTextReaderExtensions.cs | 4 +++- lib/Utils/src/Memory/MemoryUtil.cs | 6 ++++-- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'lib/Utils') 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 @@ -33,10 +32,6 @@ namespace VNLib.Utils.IO /// public interface IVnTextReader { - /// - /// The base stream to read data from - /// - Stream BaseStream { get; } /// /// The character encoding used by the TextReader /// 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 /// Allows reading lines of data from the stream without allocations public static ERRNO ReadLine(this T reader, Span charBuffer) where T : class, IVnTextReader { + ArgumentNullException.ThrowIfNull(reader); return ReadLineInternal(ref reader, charBuffer); } @@ -118,6 +119,7 @@ namespace VNLib.Utils.IO /// You should use the property to know how much remaining data is buffered public static int ReadRemaining(this T reader, Span 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 /// /// Optimized memmove for known small memory blocks. This method is faster than /// 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. /// /// /// A readonly reference to the first element in the source memory sequence @@ -999,7 +1000,7 @@ namespace VNLib.Utils.Memory /// /// 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. /// /// /// WARNING: It's not possible to do bounds checking when using references. Be sure you @@ -1034,6 +1035,7 @@ namespace VNLib.Utils.Memory /// /// 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. /// /// 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. -- cgit