diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-03-04 19:27:07 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-03-04 19:27:07 +0700 |
commit | a6715726bf540ba2466eaed927028dab08fd97f0 (patch) | |
tree | 21ca7d5091a29506580e9028d40a72f466482833 /crypto/src/asn1/DerSet.cs | |
parent | Refactoring in CipherFactory (diff) | |
download | BouncyCastle.NET-ed25519-a6715726bf540ba2466eaed927028dab08fd97f0.tar.xz |
Refactor Asn1Set classes
Diffstat (limited to 'crypto/src/asn1/DerSet.cs')
-rw-r--r-- | crypto/src/asn1/DerSet.cs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/crypto/src/asn1/DerSet.cs b/crypto/src/asn1/DerSet.cs index 3e52094c3..db4c7b1a2 100644 --- a/crypto/src/asn1/DerSet.cs +++ b/crypto/src/asn1/DerSet.cs @@ -73,17 +73,19 @@ namespace Org.BouncyCastle.Asn1 private Asn1Encodable[] GetSortedElements() { - if (isSorted) - return elements; - - int count = elements.Length; - Asn1Object[] asn1Objects = new Asn1Object[count]; - for (int i = 0; i < count; ++i) - { - asn1Objects[i] = elements[i].ToAsn1Object(); + if (m_sortedElements == null) + { + int count = m_elements.Length; + Asn1Object[] asn1Objects = new Asn1Object[count]; + for (int i = 0; i < count; ++i) + { + asn1Objects[i] = m_elements[i].ToAsn1Object(); + } + Sort(asn1Objects); + m_sortedElements = asn1Objects; } - return Sort(asn1Objects); + return m_sortedElements; } } } |