mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8267110: Update java.util to use instanceof pattern variable
Reviewed-by: lancea, naoto
This commit is contained in:
parent
0a03fc84b3
commit
a52c4ede2f
29 changed files with 142 additions and 266 deletions
|
@ -619,10 +619,9 @@ public class WeakHashMap<K,V>
|
|||
|
||||
/** Special version of remove needed by Entry set */
|
||||
boolean removeMapping(Object o) {
|
||||
if (!(o instanceof Map.Entry))
|
||||
if (!(o instanceof Map.Entry<?, ?> entry))
|
||||
return false;
|
||||
Entry<K,V>[] tab = getTable();
|
||||
Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
|
||||
Object k = maskNull(entry.getKey());
|
||||
int h = hash(k);
|
||||
int i = indexFor(h, tab.length);
|
||||
|
@ -737,9 +736,8 @@ public class WeakHashMap<K,V>
|
|||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Map.Entry))
|
||||
if (!(o instanceof Map.Entry<?, ?> e))
|
||||
return false;
|
||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
||||
K k1 = getKey();
|
||||
Object k2 = e.getKey();
|
||||
if (k1 == k2 || (k1 != null && k1.equals(k2))) {
|
||||
|
@ -977,11 +975,9 @@ public class WeakHashMap<K,V>
|
|||
}
|
||||
|
||||
public boolean contains(Object o) {
|
||||
if (!(o instanceof Map.Entry))
|
||||
return false;
|
||||
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
|
||||
Entry<K,V> candidate = getEntry(e.getKey());
|
||||
return candidate != null && candidate.equals(e);
|
||||
return o instanceof Map.Entry<?, ?> e
|
||||
&& getEntry(e.getKey()) != null
|
||||
&& getEntry(e.getKey()).equals(e);
|
||||
}
|
||||
|
||||
public boolean remove(Object o) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue