summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2020-09-04 15:31:54 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2020-09-04 15:31:54 +0700
commitc11e0f9da00fd53f14fba442b1dfb11123775e9a (patch)
tree30dc95bc582a21ef05950b972c277a2dba433175
parentadded IDigestFactory (diff)
downloadBouncyCastle.NET-ed25519-c11e0f9da00fd53f14fba442b1dfb11123775e9a.tar.xz
Remove unnecessary locking
- see https://github.com/bcgit/bc-java/issues/778
-rw-r--r--crypto/src/math/ec/ECCurve.cs13
1 files changed, 6 insertions, 7 deletions
diff --git a/crypto/src/math/ec/ECCurve.cs b/crypto/src/math/ec/ECCurve.cs
index 7d60e5f99..f011b1baf 100644
--- a/crypto/src/math/ec/ECCurve.cs
+++ b/crypto/src/math/ec/ECCurve.cs
@@ -433,18 +433,17 @@ namespace Org.BouncyCastle.Math.EC
         }
 
         /**
-         * Sets the default <code>ECMultiplier</code>, unless already set. 
+         * Sets the default <code>ECMultiplier</code>, unless already set.
+         *
+         * We avoid locking for performance reasons, so there is no uniqueness guarantee.
          */
         public virtual ECMultiplier GetMultiplier()
         {
-            lock (this)
+            if (this.m_multiplier == null)
             {
-                if (this.m_multiplier == null)
-                {
-                    this.m_multiplier = CreateDefaultMultiplier();
-                }
-                return this.m_multiplier;
+                this.m_multiplier = CreateDefaultMultiplier();
             }
+            return this.m_multiplier;
         }
 
         /**