Skip to content

Commit 214cb2c

Browse files
committed
Polishing contribution
Closes gh-36056
1 parent 26e0f55 commit 214cb2c

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ private class EntrySet extends AbstractSet<Entry<String, V>> {
437437

438438
private final Set<Entry<String, V>> delegate;
439439

440-
public EntrySet(Set<Entry<String, V>> delegate) {
440+
EntrySet(Set<Entry<String, V>> delegate) {
441441
this.delegate = delegate;
442442
}
443443

@@ -452,13 +452,10 @@ public boolean contains(Object o) {
452452
return false;
453453
}
454454
Object key = entry.getKey();
455-
if (!(key instanceof String stringKey)) {
455+
if (!LinkedCaseInsensitiveMap.this.containsKey(key)) {
456456
return false;
457457
}
458-
if (!LinkedCaseInsensitiveMap.this.containsKey(stringKey)) {
459-
return false;
460-
}
461-
V value = LinkedCaseInsensitiveMap.this.get(stringKey);
458+
V value = LinkedCaseInsensitiveMap.this.get(key);
462459
return ObjectUtils.nullSafeEquals(value, entry.getValue());
463460
}
464461

@@ -473,24 +470,20 @@ public boolean remove(Object o) {
473470
return false;
474471
}
475472
Object key = entry.getKey();
476-
if (!(key instanceof String stringKey)) {
473+
if (!LinkedCaseInsensitiveMap.this.containsKey(key)) {
477474
return false;
478475
}
479-
if (!LinkedCaseInsensitiveMap.this.containsKey(stringKey)) {
480-
return false;
481-
}
482-
V value = LinkedCaseInsensitiveMap.this.get(stringKey);
476+
V value = LinkedCaseInsensitiveMap.this.get(key);
483477
if (!ObjectUtils.nullSafeEquals(value, entry.getValue())) {
484478
return false;
485479
}
486-
LinkedCaseInsensitiveMap.this.remove(stringKey);
480+
LinkedCaseInsensitiveMap.this.remove(key);
487481
return true;
488482
}
489483

490484
@Override
491485
public void clear() {
492-
this.delegate.clear();
493-
caseInsensitiveKeys.clear();
486+
LinkedCaseInsensitiveMap.this.clear();
494487
}
495488

496489
@Override

0 commit comments

Comments
 (0)