From 21130c889bd8564b201aa16c8f645abdf85d374a Mon Sep 17 00:00:00 2001 From: vnugent Date: Sun, 31 Mar 2024 17:00:45 -0400 Subject: Squashed commit of the following: commit 448a93bb1d18d032087afe2476ffccb98634a54c Author: vnugent Date: Sun Mar 31 16:56:51 2024 -0400 ci: fix third-party dir cleanup commit 9afed1427472da1ea13079f98dbe27339e55ee7d Author: vnugent Date: Sun Mar 31 16:43:15 2024 -0400 perf: Deprecate unsafememoryhandle span extensions commit 3ff90da4f02af47ea6d233fdd4445337ebe36452 Author: vnugent Date: Sat Mar 30 21:36:18 2024 -0400 refactor: Updates, advanced tracing, http optimizations commit 8d6b79b5ae309b36f265ba81529bcef8bfcd7414 Merge: 6c1667b 5585915 Author: vnugent Date: Sun Mar 24 21:01:31 2024 -0400 Merge branch 'main' into develop commit 6c1667be23597513537f8190e2f55d65eb9b7c7a Author: vnugent Date: Fri Mar 22 12:01:53 2024 -0400 refactor: Overhauled native library loading and lazy init commit ebf688f2f974295beabf7b5def7e6f6f150551d0 Author: vnugent Date: Wed Mar 20 22:16:17 2024 -0400 refactor: Update compression header files and macros + Ci build commit 9c7b564911080ccd5cbbb9851a0757b05e1e9047 Author: vnugent Date: Tue Mar 19 21:54:49 2024 -0400 refactor: JWK overhaul & add length getter to FileUpload commit 6d8c3444e09561e5957491b3cc1ae858e0abdd14 Author: vnugent Date: Mon Mar 18 16:13:20 2024 -0400 feat: Add FNV1a software checksum and basic correction tests commit 00d182088cecefc08ca80b1faee9bed3f215f40b Author: vnugent Date: Fri Mar 15 01:05:27 2024 -0400 chore: #6 Use utils filewatcher instead of built-in commit d513c10d9895c6693519ef1d459c6a5a76929436 Author: vnugent Date: Sun Mar 10 21:58:14 2024 -0400 source tree project location updated --- lib/Utils/src/Extensions/MemoryExtensions.cs | 52 +++------------------------- 1 file changed, 5 insertions(+), 47 deletions(-) (limited to 'lib/Utils/src/Extensions') diff --git a/lib/Utils/src/Extensions/MemoryExtensions.cs b/lib/Utils/src/Extensions/MemoryExtensions.cs index 8f90525..65d90a0 100644 --- a/lib/Utils/src/Extensions/MemoryExtensions.cs +++ b/lib/Utils/src/Extensions/MemoryExtensions.cs @@ -50,6 +50,8 @@ namespace VNLib.Utils.Extensions /// A new encapsulating the rented array public static UnsafeMemoryHandle UnsafeAlloc(this ArrayPool pool, int size, bool zero = false) where T : unmanaged { + ArgumentNullException.ThrowIfNull(pool); + T[] array = pool.Rent(size); if (zero) @@ -268,7 +270,7 @@ namespace VNLib.Utils.Extensions /// /// Gets a reference to the element at the specified offset from the base - /// address of the + /// address of the /// /// /// The element offset from the base address to add to the returned reference @@ -765,52 +767,6 @@ namespace VNLib.Utils.Extensions #endregion - /// - /// Slices the current array by the specified starting offset to the end - /// of the array - /// - /// The array type - /// - /// The start offset of the new array slice - /// The sliced array - /// - public static T[] Slice(this T[] arr, int start) - { - ArgumentNullException.ThrowIfNull(arr); - ArgumentOutOfRangeException.ThrowIfNegative(start); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(start, arr.Length); - - Range sliceRange = new(start, arr.Length - start); - return RuntimeHelpers.GetSubArray(arr, sliceRange); - } - - /// - /// Slices the current array by the specified starting offset to including the - /// speciifed number of items - /// - /// The array type - /// - /// The start offset of the new array slice - /// The size of the new array - /// The sliced array - /// - public static T[] Slice(this T[] arr, int start, int count) - { - ArgumentNullException.ThrowIfNull(arr); - ArgumentOutOfRangeException.ThrowIfNegative(start); - ArgumentOutOfRangeException.ThrowIfNegative(count); - ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(start + count, arr.Length); - - if(count == 0) - { - return []; - } - - //Calc the slice range - Range sliceRange = new(start, start + count); - return RuntimeHelpers.GetSubArray(arr, sliceRange); - } - /// /// Creates a new sub-sequence over the target handle. (allows for convient sub span) /// @@ -877,6 +833,7 @@ namespace VNLib.Utils.Extensions /// The sub-sequence of the current handle /// [MethodImpl(MethodImplOptions.AggressiveInlining)] + [Obsolete("Functions are included directly on the type now")] public static Span AsSpan(this in UnsafeMemoryHandle handle, int start) where T: unmanaged => handle.Span[start..]; /// @@ -889,6 +846,7 @@ namespace VNLib.Utils.Extensions /// The sub-sequence of the current handle /// [MethodImpl(MethodImplOptions.AggressiveInlining)] + [Obsolete("Functions are included directly on the type now")] public static Span AsSpan(this in UnsafeMemoryHandle handle, int start, int count) where T : unmanaged => handle.Span.Slice(start, count); /// -- cgit