diff --git a/core/src/main/java/org/jruby/anno/AnnotationHelper.java b/core/src/main/java/org/jruby/anno/AnnotationHelper.java index a51dde39d6d..1047cb37cba 100644 --- a/core/src/main/java/org/jruby/anno/AnnotationHelper.java +++ b/core/src/main/java/org/jruby/anno/AnnotationHelper.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.StringJoiner; import java.util.function.BiConsumer; import java.util.stream.Collectors; @@ -103,15 +104,20 @@ public static void groupFrameFields(Map, List> readGroup public static void populateMethodIndex(Map, List> accessGroups, BiConsumer action) { if (!accessGroups.isEmpty()) { - for (Map.Entry, List> accessEntry : accessGroups.entrySet()) { - Set reads = accessEntry.getKey(); - List names = accessEntry.getValue(); - + accessGroups.forEach((reads, names) -> { int bits = FrameField.pack(reads.stream().toArray(n -> new FrameField[n])); - String namesJoined = names.stream().distinct().collect(Collectors.joining(";")); + + StringJoiner joiner = new StringJoiner(";"); + Set uniqueValues = new HashSet<>(); + for (String name : names) { + if (uniqueValues.add(name)) { + joiner.add(name); + } + } + String namesJoined = joiner.toString(); action.accept(bits, namesJoined); - } + }); } }