Optimize collection usage in CGLIB fork

Closes gh-30993
This commit is contained in:
ali dandach 2023-08-04 00:22:53 +03:00 committed by Sam Brannen
parent faf3c7831f
commit 6dbd684279
2 changed files with 2 additions and 10 deletions

View File

@ -52,12 +52,7 @@ public class CollectionUtils {
} }
public static Collection filter(Collection c, Predicate p) { public static Collection filter(Collection c, Predicate p) {
Iterator it = c.iterator(); c.removeIf(o -> !p.evaluate(o));
while (it.hasNext()) {
if (!p.evaluate(it.next())) {
it.remove();
}
}
return c; return c;
} }

View File

@ -22,10 +22,7 @@ public class CustomizerRegistry {
Class<? extends KeyFactoryCustomizer> klass = customizer.getClass(); Class<? extends KeyFactoryCustomizer> klass = customizer.getClass();
for (Class type : customizerTypes) { for (Class type : customizerTypes) {
if (type.isAssignableFrom(klass)) { if (type.isAssignableFrom(klass)) {
List<KeyFactoryCustomizer> list = customizers.get(type); List<KeyFactoryCustomizer> list = customizers.computeIfAbsent(type, k -> new ArrayList<>());
if (list == null) {
customizers.put(type, list = new ArrayList<>());
}
list.add(customizer); list.add(customizer);
} }
} }