diff options
author | vnugent <public@vaughnnugent.com> | 2024-06-18 21:17:28 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-06-18 21:17:28 -0400 |
commit | ee3620b8168a42c8e571e853c751ad5999a9b907 (patch) | |
tree | 4134b47ace8b5b46ff4909ab198fcd6f50c3bd18 /lib/Utils/src/Extensions | |
parent | ff0926be56fc6eafdce36411847d73bf4ce9f183 (diff) |
feat: Add file path caching support
Diffstat (limited to 'lib/Utils/src/Extensions')
-rw-r--r-- | lib/Utils/src/Extensions/MemoryExtensions.cs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Utils/src/Extensions/MemoryExtensions.cs b/lib/Utils/src/Extensions/MemoryExtensions.cs index 99d4cf1..f2399a2 100644 --- a/lib/Utils/src/Extensions/MemoryExtensions.cs +++ b/lib/Utils/src/Extensions/MemoryExtensions.cs @@ -268,6 +268,23 @@ 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}"/> and casts it to a byte reference + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="block"></param> + /// <param name="offset">The number of elements to offset the base reference by</param> + /// <returns>The reinterpreted byte reference at the first byte of the element offset</returns> + /// <exception cref="ArgumentNullException"></exception> + /// <exception cref="ArgumentOutOfRangeException"></exception> + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ref byte GetOffsetByteRef<T>(this IMemoryHandle<T> block, nint offset) + { + ArgumentOutOfRangeException.ThrowIfNegative(offset); + return ref GetOffsetByteRef(block, (nuint)offset); + } + + /// <summary> /// Gets a 64bit friendly span offset for the current <see cref="MemoryHandle{T}"/> /// </summary> /// <typeparam name="T"></typeparam> |