aboutsummaryrefslogtreecommitdiff
path: root/lib/Utils/src/Extensions
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-03-31 17:00:45 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-03-31 17:00:45 -0400
commit21130c889bd8564b201aa16c8f645abdf85d374a (patch)
tree57e685f0f7e5c341264eb890112de35206f3d289 /lib/Utils/src/Extensions
parent55859158fbd0bf54473a0baeb486045a025c7c5d (diff)
Squashed commit of the following:
commit 448a93bb1d18d032087afe2476ffccb98634a54c Author: vnugent <public@vaughnnugent.com> Date: Sun Mar 31 16:56:51 2024 -0400 ci: fix third-party dir cleanup commit 9afed1427472da1ea13079f98dbe27339e55ee7d Author: vnugent <public@vaughnnugent.com> Date: Sun Mar 31 16:43:15 2024 -0400 perf: Deprecate unsafememoryhandle span extensions commit 3ff90da4f02af47ea6d233fdd4445337ebe36452 Author: vnugent <public@vaughnnugent.com> Date: Sat Mar 30 21:36:18 2024 -0400 refactor: Updates, advanced tracing, http optimizations commit 8d6b79b5ae309b36f265ba81529bcef8bfcd7414 Merge: 6c1667b 5585915 Author: vnugent <public@vaughnnugent.com> Date: Sun Mar 24 21:01:31 2024 -0400 Merge branch 'main' into develop commit 6c1667be23597513537f8190e2f55d65eb9b7c7a Author: vnugent <public@vaughnnugent.com> Date: Fri Mar 22 12:01:53 2024 -0400 refactor: Overhauled native library loading and lazy init commit ebf688f2f974295beabf7b5def7e6f6f150551d0 Author: vnugent <public@vaughnnugent.com> Date: Wed Mar 20 22:16:17 2024 -0400 refactor: Update compression header files and macros + Ci build commit 9c7b564911080ccd5cbbb9851a0757b05e1e9047 Author: vnugent <public@vaughnnugent.com> Date: Tue Mar 19 21:54:49 2024 -0400 refactor: JWK overhaul & add length getter to FileUpload commit 6d8c3444e09561e5957491b3cc1ae858e0abdd14 Author: vnugent <public@vaughnnugent.com> Date: Mon Mar 18 16:13:20 2024 -0400 feat: Add FNV1a software checksum and basic correction tests commit 00d182088cecefc08ca80b1faee9bed3f215f40b Author: vnugent <public@vaughnnugent.com> Date: Fri Mar 15 01:05:27 2024 -0400 chore: #6 Use utils filewatcher instead of built-in commit d513c10d9895c6693519ef1d459c6a5a76929436 Author: vnugent <public@vaughnnugent.com> Date: Sun Mar 10 21:58:14 2024 -0400 source tree project location updated
Diffstat (limited to 'lib/Utils/src/Extensions')
-rw-r--r--lib/Utils/src/Extensions/MemoryExtensions.cs52
1 files changed, 5 insertions, 47 deletions
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
/// <returns>A new <see cref="OpenResourceHandle{T}"/> encapsulating the rented array</returns>
public static UnsafeMemoryHandle<T> UnsafeAlloc<T>(this ArrayPool<T> 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
/// <summary>
/// Gets a reference to the element at the specified offset from the base
- /// address of the <see cref="MemoryHandle{T}"/>
+ /// address of the <see cref="IMemoryHandle{T}"/>
/// </summary>
/// <param name="block"></param>
/// <param name="offset">The element offset from the base address to add to the returned reference</param>
@@ -766,52 +768,6 @@ namespace VNLib.Utils.Extensions
#endregion
/// <summary>
- /// Slices the current array by the specified starting offset to the end
- /// of the array
- /// </summary>
- /// <typeparam name="T">The array type</typeparam>
- /// <param name="arr"></param>
- /// <param name="start">The start offset of the new array slice</param>
- /// <returns>The sliced array</returns>
- /// <exception cref="ArgumentOutOfRangeException"></exception>
- public static T[] Slice<T>(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);
- }
-
- /// <summary>
- /// Slices the current array by the specified starting offset to including the
- /// speciifed number of items
- /// </summary>
- /// <typeparam name="T">The array type</typeparam>
- /// <param name="arr"></param>
- /// <param name="start">The start offset of the new array slice</param>
- /// <param name="count">The size of the new array</param>
- /// <returns>The sliced array</returns>
- /// <exception cref="ArgumentOutOfRangeException"></exception>
- public static T[] Slice<T>(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);
- }
-
- /// <summary>
/// Creates a new sub-sequence over the target handle. (allows for convient sub span)
/// </summary>
/// <typeparam name="T"></typeparam>
@@ -877,6 +833,7 @@ namespace VNLib.Utils.Extensions
/// <returns>The sub-sequence of the current handle</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [Obsolete("Functions are included directly on the type now")]
public static Span<T> AsSpan<T>(this in UnsafeMemoryHandle<T> handle, int start) where T: unmanaged => handle.Span[start..];
/// <summary>
@@ -889,6 +846,7 @@ namespace VNLib.Utils.Extensions
/// <returns>The sub-sequence of the current handle</returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [Obsolete("Functions are included directly on the type now")]
public static Span<T> AsSpan<T>(this in UnsafeMemoryHandle<T> handle, int start, int count) where T : unmanaged => handle.Span.Slice(start, count);
/// <summary>