From 80e09a9e596a4812d5f66db73ee8a29bdf58b4c7 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 23 Jan 2017 17:49:48 +0300 Subject: [PATCH] removed unnecessary underlyingMapSize() --- .../util/containers/ConcurrentMapsTest.java | 20 ++----------------- .../util/containers/ConcurrentRefHashMap.java | 6 ------ .../containers/ConcurrentRefValueHashMap.java | 6 ------ .../intellij/util/containers/RefHashMap.java | 6 ------ 4 files changed, 2 insertions(+), 36 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/util/containers/ConcurrentMapsTest.java b/platform/platform-tests/testSrc/com/intellij/util/containers/ConcurrentMapsTest.java index f0a99e3e774d..d1885ead4f9e 100644 --- a/platform/platform-tests/testSrc/com/intellij/util/containers/ConcurrentMapsTest.java +++ b/platform/platform-tests/testSrc/com/intellij/util/containers/ConcurrentMapsTest.java @@ -15,9 +15,7 @@ */ package com.intellij.util.containers; -import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.testFramework.UsefulTestCase; import com.intellij.util.GCUtil; import gnu.trove.TObjectHashingStrategy; import org.junit.Test; @@ -53,21 +51,7 @@ public class ConcurrentMapsTest { @Test(timeout = TIMEOUT) public void testWeakHashMapWithIdentityStrategy() { WeakHashMap map = new WeakHashMap<>(10,0.5f,ContainerUtil.identityStrategy()); - Ref key = Ref.create(new Object()); - Ref value = Ref.create(new Object()); - map.put(key.get(), value.get()); - - assertSame(value.get(), map.get(key.get())); - value.set(null); - key.set(null); - do { - GCUtil.tryGcSoftlyReachableObjects(); - System.gc(); - } - while (!map.processQueue()); - assertEquals(0, map.underlyingMapSize()); - UsefulTestCase.assertEmpty(map.keySet()); - assertTrue(map.isEmpty()); + checkKeyIsTossedAfterGCPressure(map); } @Test(timeout = TIMEOUT) @@ -112,7 +96,7 @@ public class ConcurrentMapsTest { checkKeyIsTossedAfterGCPressure(map); } - private void checkKeyIsTossedAfterGCPressure(ConcurrentMap map) { + private void checkKeyIsTossedAfterGCPressure(Map map) { map.put(new Object(), new Object()); //noinspection SizeReplaceableByIsEmpty diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentRefHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentRefHashMap.java index 06791a22e195..ece7482eff3d 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentRefHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentRefHashMap.java @@ -25,7 +25,6 @@ package com.intellij.util.containers; import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; import java.lang.ref.ReferenceQueue; import java.util.*; @@ -407,9 +406,4 @@ abstract class ConcurrentRefHashMap extends AbstractMap implements C public boolean equals(final K o1, final K o2) { return o1.equals(o2); } - - @TestOnly - int underlyingMapSize() { - return myMap.size(); - } } diff --git a/platform/util/src/com/intellij/util/containers/ConcurrentRefValueHashMap.java b/platform/util/src/com/intellij/util/containers/ConcurrentRefValueHashMap.java index b410abb6cf51..c914abe8b38f 100644 --- a/platform/util/src/com/intellij/util/containers/ConcurrentRefValueHashMap.java +++ b/platform/util/src/com/intellij/util/containers/ConcurrentRefValueHashMap.java @@ -19,7 +19,6 @@ package com.intellij.util.containers; import com.intellij.openapi.util.text.StringUtil; import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; import java.lang.ref.ReferenceQueue; import java.util.ArrayList; @@ -239,9 +238,4 @@ abstract class ConcurrentRefValueHashMap implements ConcurrentMap { public String toString() { return "map size:" + size() + " [" + StringUtil.join(entrySet(), ",") + "]"; } - - @TestOnly - int underlyingMapSize() { - return myMap.size(); - } } diff --git a/platform/util/src/com/intellij/util/containers/RefHashMap.java b/platform/util/src/com/intellij/util/containers/RefHashMap.java index 4390ccf3aaa6..eeeac98406de 100644 --- a/platform/util/src/com/intellij/util/containers/RefHashMap.java +++ b/platform/util/src/com/intellij/util/containers/RefHashMap.java @@ -18,7 +18,6 @@ package com.intellij.util.containers; import gnu.trove.THashMap; import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; import java.lang.ref.ReferenceQueue; import java.util.*; @@ -387,9 +386,4 @@ abstract class RefHashMap extends AbstractMap implements Map { if (entrySet == null) entrySet = new EntrySet(); return entrySet; } - - @TestOnly - int underlyingMapSize() { - return myMap.size(); - } }