Skip to content

Commit

Permalink
Trivial refactor: use enhanced for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellansun committed Aug 24, 2024
1 parent 697e459 commit 2b7e779
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/codehaus/groovy/ast/ClassNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ public void setInterfaces(final ClassNode[] interfaces) {
this.interfaces = interfaces;
// GROOVY-10763: update generics indicator
if (interfaces != null && !usesGenerics && isPrimaryNode) {
for (int i = 0, n = interfaces.length; i < n; i += 1) {
usesGenerics |= interfaces[i].isUsingGenerics();
for (ClassNode anInterface : interfaces) {
usesGenerics |= anInterface.isUsingGenerics();
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/codehaus/groovy/ast/ModuleNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,7 @@ private MethodNode handleMainMethodIfPresent(final List<MethodNode> methods) {
boolean foundInstance = false;
boolean foundStatic = false;
MethodNode result = null;
for (Iterator<MethodNode> iter = methods.iterator(); iter.hasNext(); ) {
MethodNode node = iter.next();
for (MethodNode node : methods) {
if (node.getName().equals("main") && !node.isPrivate()) {
int numParams = node.getParameters().length;
if (numParams < 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4797,9 +4797,9 @@ public static <E extends T, T, V extends T> T inject(E[] self, @ClosureParams(va
public static <E, T, U extends T, V extends T> T inject(E[] self, U initialValue, @ClosureParams(value=FromString.class,options="T,E") Closure<V> closure) {
T value = initialValue;
Object[] params = new Object[2];
for (int i = 0; i < self.length; i += 1) {
for (E e : self) {
params[0] = value;
params[1] = self[i];
params[1] = e;
value = closure.call(params);
}
return value;
Expand Down

0 comments on commit 2b7e779

Please sign in to comment.