Skip to content

Commit 5c09dfa

Browse files
committed
Tiny refactor to address a niggly bit of code
1 parent b27ea1f commit 5c09dfa

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

‎hamcrest-library/src/main/java/org/hamcrest/collection/IsIterableWithSize.java‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,18 @@
33
import org.hamcrest.FeatureMatcher;
44
import org.hamcrest.Matcher;
55

6-
import java.util.Iterator;
7-
86
public class IsIterableWithSize<E> extends FeatureMatcher<Iterable<E>, Integer> {
9-
107
public IsIterableWithSize(Matcher<? super Integer> sizeMatcher) {
118
super(sizeMatcher, "an iterable with size", "iterable size");
129
}
13-
10+
1411

1512
@Override
1613
protected Integer featureValueOf(Iterable<E> actual) {
17-
int size = 0;
18-
for (Iterator<E> iterator = actual.iterator(); iterator.hasNext(); iterator.next()) {
19-
size++;
20-
}
21-
return size;
14+
int size = 0;
15+
for (E e : actual) {
16+
size++;
17+
}
18+
return size;
2219
}
23-
2420
}

0 commit comments

Comments
 (0)