Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,9 @@ private void createMethods(ImClass c, LuaVariable classVar) {
groups.sort(Comparator.comparing(group -> group.isEmpty() ? "" : methodSortKey(group.get(0))));
List<List<ImMethod>> preparedGroups = new ArrayList<>();
Map<List<ImMethod>, ImMethod> chosenByGroup = new LinkedHashMap<>();
// Both passes below read the slot names of every group and the names of its members; they are made once.
Map<List<ImMethod>, Set<String>> slotNamesByGroup = new IdentityHashMap<>();
Map<List<ImMethod>, Set<String>> memberNamesByGroup = new IdentityHashMap<>();
for (List<ImMethod> groupMethods : groups) {
if (groupMethods == null || groupMethods.isEmpty()) {
continue;
Expand All @@ -1700,6 +1703,12 @@ private void createMethods(ImClass c, LuaVariable classVar) {
}
preparedGroups.add(groupMethods);
chosenByGroup.put(groupMethods, chosen);
Set<String> memberNames = new HashSet<>();
for (ImMethod m : groupMethods) {
memberNames.add(dispatchSlotName(m.getName()));
}
memberNamesByGroup.put(groupMethods, memberNames);
slotNamesByGroup.put(groupMethods, collectDispatchSlotNames(c, groupMethods));
}

// Slots are assigned in two passes: a slot name that is the (normalized)
Expand All @@ -1715,11 +1724,8 @@ private void createMethods(ImClass c, LuaVariable classVar) {
Set<String> directSlots = new HashSet<>();
for (List<ImMethod> groupMethods : preparedGroups) {
ImMethod chosen = chosenByGroup.get(groupMethods);
Set<String> memberNames = new HashSet<>();
for (ImMethod m : groupMethods) {
memberNames.add(dispatchSlotName(m.getName()));
}
Set<String> slotNames = collectDispatchSlotNames(c, groupMethods);
Set<String> memberNames = memberNamesByGroup.get(groupMethods);
Set<String> slotNames = slotNamesByGroup.get(groupMethods);
for (String slotName : slotNames) {
if (!memberNames.contains(slotName)) {
continue;
Expand All @@ -1735,11 +1741,8 @@ private void createMethods(ImClass c, LuaVariable classVar) {
}
for (List<ImMethod> groupMethods : preparedGroups) {
ImMethod chosen = chosenByGroup.get(groupMethods);
Set<String> memberNames = new HashSet<>();
for (ImMethod m : groupMethods) {
memberNames.add(dispatchSlotName(m.getName()));
}
for (String slotName : collectDispatchSlotNames(c, groupMethods)) {
Set<String> memberNames = memberNamesByGroup.get(groupMethods);
for (String slotName : slotNamesByGroup.get(groupMethods)) {
if (memberNames.contains(slotName)) {
continue;
}
Expand Down
Loading