Skip to content

Commit

Permalink
Optimize default implementation of Iterable.forEachRemaining
Browse files Browse the repository at this point in the history
  • Loading branch information
mpfaff committed Apr 11, 2024
1 parent bea496b commit d838e1b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/java.base/share/classes/java/lang/Iterable.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ public interface Iterable<T> {
* @since 1.8
*/
default void forEach(Consumer<? super T> action) {
Objects.requireNonNull(action);
for (T t : this) {
action.accept(t);
}
this.spliterator().forEachRemaining(action);
}

/**
Expand Down

0 comments on commit d838e1b

Please sign in to comment.