summary refs log tree commit diff
path: root/crypto/src/asn1/Asn1RelativeOid.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/Asn1RelativeOid.cs')
-rw-r--r--crypto/src/asn1/Asn1RelativeOid.cs21
1 files changed, 5 insertions, 16 deletions
diff --git a/crypto/src/asn1/Asn1RelativeOid.cs b/crypto/src/asn1/Asn1RelativeOid.cs
index b7df4b75a..1d2ecb3df 100644
--- a/crypto/src/asn1/Asn1RelativeOid.cs
+++ b/crypto/src/asn1/Asn1RelativeOid.cs
@@ -137,8 +137,11 @@ namespace Org.BouncyCastle.Asn1
             return new PrimitiveDerEncoding(tagClass, tagNo, GetContents());
         }
 
-        private void DoOutput(MemoryStream bOut)
+        private byte[] GetContents() => Objects.EnsureSingletonInitialized(ref contents, identifier, CreateContents);
+
+        private static byte[] CreateContents(string identifier)
         {
+            MemoryStream bOut = new MemoryStream();
             OidTokenizer tok = new OidTokenizer(identifier);
             while (tok.HasMoreTokens)
             {
@@ -152,21 +155,7 @@ namespace Org.BouncyCastle.Asn1
                     WriteField(bOut, new BigInteger(token));
                 }
             }
-        }
-
-        private byte[] GetContents()
-        {
-            lock (this)
-            {
-                if (contents == null)
-                {
-                    MemoryStream bOut = new MemoryStream();
-                    DoOutput(bOut);
-                    contents = bOut.ToArray();
-                }
-
-                return contents;
-            }
+            return bOut.ToArray();
         }
 
         internal static Asn1RelativeOid CreatePrimitive(byte[] contents, bool clone)