removed unnecessary underlyingMapSize()

This commit is contained in:
Alexey Kudravtsev
2017-01-23 17:49:48 +03:00
parent bb61ebaf4c
commit 80e09a9e59
4 changed files with 2 additions and 36 deletions

View File

@@ -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<Object, Object> map = new WeakHashMap<>(10,0.5f,ContainerUtil.identityStrategy());
Ref<Object> key = Ref.create(new Object());
Ref<Object> 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<Object, Object> map) {
private void checkKeyIsTossedAfterGCPressure(Map<Object, Object> map) {
map.put(new Object(), new Object());
//noinspection SizeReplaceableByIsEmpty

View File

@@ -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<K, V> extends AbstractMap<K, V> implements C
public boolean equals(final K o1, final K o2) {
return o1.equals(o2);
}
@TestOnly
int underlyingMapSize() {
return myMap.size();
}
}

View File

@@ -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<K, V> implements ConcurrentMap<K, V> {
public String toString() {
return "map size:" + size() + " [" + StringUtil.join(entrySet(), ",") + "]";
}
@TestOnly
int underlyingMapSize() {
return myMap.size();
}
}

View File

@@ -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<K, V> extends AbstractMap<K, V> implements Map<K, V> {
if (entrySet == null) entrySet = new EntrySet();
return entrySet;
}
@TestOnly
int underlyingMapSize() {
return myMap.size();
}
}