diff options
author | Peter Dettman <peter.dettman@gmail.com> | 2022-10-17 17:48:11 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@gmail.com> | 2022-10-17 17:48:11 +0700 |
commit | 6b82d749f14943082790cfecda9674521e098b07 (patch) | |
tree | a2565b09c54a1500d9c093076c6b0d1a9f59a6fa /crypto/src | |
parent | Mark some tests NonParallelizable (diff) | |
download | BouncyCastle.NET-ed25519-6b82d749f14943082790cfecda9674521e098b07.tar.xz |
Compare byte arrays using SequenceCompareTo
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/asn1/Asn1Set.cs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/src/asn1/Asn1Set.cs b/crypto/src/asn1/Asn1Set.cs index b2a654d68..faec50eb0 100644 --- a/crypto/src/asn1/Asn1Set.cs +++ b/crypto/src/asn1/Asn1Set.cs @@ -306,6 +306,10 @@ namespace Org.BouncyCastle.Asn1 if (a0 != b0) return a0 < b0 ? -1 : 1; +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + int compareLength = System.Math.Min(a.Length, b.Length) - 1; + return a.AsSpan(1, compareLength).SequenceCompareTo(b.AsSpan(1, compareLength)); +#else int len = System.Math.Min(a.Length, b.Length); for (int i = 1; i < len; ++i) { @@ -315,6 +319,7 @@ namespace Org.BouncyCastle.Asn1 } Debug.Assert(a.Length == b.Length); return 0; +#endif } } } |