ExplicitArrayFillingInspection: simplified test (IJ-CR-9863)

GitOrigin-RevId: 8a3a6eb1f8e5bbf2c73bebf2bdbfc489e7a5d136
This commit is contained in:
Artemiy Sartakov
2021-06-09 10:31:03 +00:00
committed by intellij-monorepo-bot
parent 998b2f9452
commit 493bf08f7c
2 changed files with 12 additions and 53 deletions
@@ -3,35 +3,14 @@ package pack;
import java.util.Arrays;
public class HashMap<K,V> {
static class Node<K,V> {
final int hash;
final K key;
V value;
Node<K,V> next;
public class TableWrapper {
Node(int hash, K key, V value, Node<K,V> next) {
this.hash = hash;
this.key = key;
this.value = value;
this.next = next;
}
}
transient Node<K,V>[] table;
transient int size;
transient int modCount;
}
int[] table;
public void clear() {
Node<K,V>[] tab;
modCount++;
if ((tab = table) != null && size > 0) {
size = 0;
Arrays.fill(tab, null);
int[] tab;
if ((tab = table) != null && table.length > 0) {
Arrays.fill(tab, 0);
}
}
}
@@ -1,36 +1,16 @@
// "Replace loop with 'Arrays.fill()' method call" "true"
package pack;
public class HashMap<K,V> {
static class Node<K,V> {
final int hash;
final K key;
V value;
Node<K,V> next;
public class TableWrapper {
Node(int hash, K key, V value, Node<K,V> next) {
this.hash = hash;
this.key = key;
this.value = value;
this.next = next;
}
}
transient Node<K,V>[] table;
transient int size;
transient int modCount;
}
int[] table;
public void clear() {
Node<K,V>[] tab;
modCount++;
if ((tab = table) != null && size > 0) {
size = 0;
for (<caret>int i = 0; i < tab.length; ++i)
tab[i] = null;
int[] tab;
if ((tab = table) != null && table.length > 0) {
for (int<caret> i = 0; i < tab.length; ++i) {
tab[i] = 0;
}
}
}
}