summary refs log tree commit diff
path: root/crypto/src/util/Spans.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/util/Spans.cs')
-rw-r--r--crypto/src/util/Spans.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crypto/src/util/Spans.cs b/crypto/src/util/Spans.cs
new file mode 100644
index 000000000..5e1b3737c
--- /dev/null
+++ b/crypto/src/util/Spans.cs
@@ -0,0 +1,18 @@
+#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
+using System;
+using System.Runtime.CompilerServices;
+
+#nullable enable
+
+namespace Org.BouncyCastle.Utilities
+{
+    internal static class Spans
+    {
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal static Span<T> FromNullable<T>(T[]? array, int start)
+        {
+            return array == null ? Span<T>.Empty : array.AsSpan(start);
+        }
+    }
+}
+#endif