From b1b4016eb80fe17bba1748c38f6ce55980ce4e55 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 3 Aug 2010 16:26:27 +0400 Subject: [PATCH] cleanup --- .../containers/LockPoolSynchronizedMap.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/platform/util/src/com/intellij/util/containers/LockPoolSynchronizedMap.java b/platform/util/src/com/intellij/util/containers/LockPoolSynchronizedMap.java index 4a5c5fb39bcf..e75471b6910b 100644 --- a/platform/util/src/com/intellij/util/containers/LockPoolSynchronizedMap.java +++ b/platform/util/src/com/intellij/util/containers/LockPoolSynchronizedMap.java @@ -35,9 +35,8 @@ public class LockPoolSynchronizedMap extends THashMap implements Con private static final JBReentrantReadWriteLock[] ourLocks = new JBReentrantReadWriteLock[NUM_LOCKS]; private static int ourLockAllocationCounter = 0; - private final JBReentrantReadWriteLock mutex = allocateLock(); - private final JBLock r = mutex.readLock(); - private final JBLock w = mutex.writeLock(); + private final JBLock r; + private final JBLock w; static { for (int i = 0; i < ourLocks.length; i++) { @@ -45,6 +44,11 @@ public class LockPoolSynchronizedMap extends THashMap implements Con } } + { + final JBReentrantReadWriteLock mutex = allocateLock(); + r = mutex.readLock(); + w = mutex.writeLock(); + } public LockPoolSynchronizedMap() { } @@ -250,14 +254,11 @@ public class LockPoolSynchronizedMap extends THashMap implements Con public boolean remove(Object key, Object oldValue) { w.lock(); try { - if (!Comparing.equal(oldValue, get(key))) { - return false; - } - return super.remove(key) != null; + V currentValue = get(key); + return Comparing.equal(oldValue, currentValue) && super.remove(key) != null; } finally { w.unlock(); } } - }