mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-09 11:53:46 +02:00
refactor: replace while with iterator with foreach loop
This commit is contained in:
@@ -37,18 +37,16 @@ package sonia.scm.search;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.TransformFilter;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -165,23 +163,18 @@ public final class SearchUtil
|
||||
List<T> items = new ArrayList<T>();
|
||||
int index = 0;
|
||||
int counter = 0;
|
||||
Iterator<T> it = collection.iterator();
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
T item = filter.accept(it.next());
|
||||
for (final T aCollection : collection) {
|
||||
T item = filter.accept(aCollection);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
if (item != null) {
|
||||
index++;
|
||||
|
||||
if (searchRequest.getStartWith() <= index)
|
||||
{
|
||||
if (searchRequest.getStartWith() <= index) {
|
||||
items.add(item);
|
||||
counter++;
|
||||
|
||||
if (searchRequest.getMaxResults() <= counter)
|
||||
{
|
||||
if (searchRequest.getMaxResults() <= counter) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,22 +235,15 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
revWalk.markStart(revWalk.lookupCommit(head));
|
||||
}
|
||||
|
||||
Iterator<RevCommit> iterator = revWalk.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
RevCommit commit = iterator.next();
|
||||
|
||||
for (final RevCommit commit : revWalk) {
|
||||
if ((counter >= start)
|
||||
&& ((limit < 0) || (counter < start + limit)))
|
||||
{
|
||||
&& ((limit < 0) || (counter < start + limit))) {
|
||||
changesetList.add(converter.createChangeset(commit));
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
if ((endId != null) && commit.getId().equals(endId))
|
||||
{
|
||||
if ((endId != null) && commit.getId().equals(endId)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user