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) {
Iterator it = c.iterator();
while (it.hasNext()) {
if (!p.evaluate(it.next())) {
it.remove();
}
}
c.removeIf(o -> !p.evaluate(o));
return c;
}

View File

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