Skip to content

Commit 9c72d34

Browse files
committed
Fix duplication
1 parent b1b40b6 commit 9c72d34

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/main/java/org/truffleruby/core/module/ModuleFields.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -878,13 +878,7 @@ public Collection<RubySymbol> filterMethods(RubyLanguage language, boolean inclu
878878
if (includeAncestors) {
879879
allMethods = ModuleOperations.getAllMethods(rubyModule);
880880
} else {
881-
Map<String, InternalMethod> results = new HashMap<>();
882-
for (Entry<String, MethodEntry> e : methods.entrySet()) {
883-
if (e.getValue().getMethod() != null) {
884-
results.put(e.getKey(), e.getValue().getMethod());
885-
}
886-
}
887-
allMethods = results;
881+
allMethods = getInternalMethodMap();
888882
}
889883
return filterMethods(language, allMethods, filter);
890884
}
@@ -910,13 +904,7 @@ public Collection<RubySymbol> filterSingletonMethods(
910904
if (includeAncestors) {
911905
allMethods = ModuleOperations.getMethodsBeforeLogicalClass(rubyModule);
912906
} else {
913-
Map<String, InternalMethod> results = new HashMap<>();
914-
for (Entry<String, MethodEntry> e : methods.entrySet()) {
915-
if (e.getValue().getMethod() != null) {
916-
results.put(e.getKey(), e.getValue().getMethod());
917-
}
918-
}
919-
allMethods = results;
907+
allMethods = getInternalMethodMap();
920908
}
921909
return filterMethods(language, allMethods, filter);
922910
}
@@ -937,6 +925,16 @@ public Collection<RubySymbol> filterMethods(
937925
return filtered;
938926
}
939927

928+
private Map<String, InternalMethod> getInternalMethodMap() {
929+
Map<String, InternalMethod> map = new HashMap<>();
930+
for (Entry<String, MethodEntry> e : methods.entrySet()) {
931+
if (e.getValue().getMethod() != null) {
932+
map.put(e.getKey(), e.getValue().getMethod());
933+
}
934+
}
935+
return map;
936+
}
937+
940938
public RubyClass getLogicalClass() {
941939
return rubyModule.getLogicalClass();
942940
}

0 commit comments

Comments
 (0)