From 58b53813749d0589891fd94355db5f9895f919f3 Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Wed, 13 Oct 2021 16:55:36 +0800 Subject: [PATCH] use Arrays.fill (#1989) --- .../arthas/common/concurrent/ConcurrentWeakKeyHashMap.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/taobao/arthas/common/concurrent/ConcurrentWeakKeyHashMap.java b/common/src/main/java/com/taobao/arthas/common/concurrent/ConcurrentWeakKeyHashMap.java index a77770b2..2bff807b 100644 --- a/common/src/main/java/com/taobao/arthas/common/concurrent/ConcurrentWeakKeyHashMap.java +++ b/common/src/main/java/com/taobao/arthas/common/concurrent/ConcurrentWeakKeyHashMap.java @@ -26,6 +26,7 @@ import java.lang.ref.WeakReference; import java.util.AbstractCollection; import java.util.AbstractMap; import java.util.AbstractSet; +import java.util.Arrays; import java.util.Collection; import java.util.ConcurrentModificationException; import java.util.Enumeration; @@ -619,10 +620,7 @@ public final class ConcurrentWeakKeyHashMap extends AbstractMap impl if (count != 0) { lock(); try { - HashEntry[] tab = table; - for (int i = 0; i < tab.length; i ++) { - tab[i] = null; - } + Arrays.fill(table, null); ++ modCount; // replace the reference queue to avoid unnecessary stale // cleanups