Skip to content

Commit

Permalink
sort via java streams instead
Browse files Browse the repository at this point in the history
  • Loading branch information
magibney committed Apr 12, 2024
1 parent 9ff5760 commit 1d1b47f
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockFactory;
Expand Down Expand Up @@ -300,9 +300,7 @@ private static Iterable<CacheValue> sorted(Set<CacheValue> vals) {
}
// here we reverse-sort entries by path, in order to trivially ensure that
// subpaths are removed before parent paths.
CacheValue[] ret = vals.toArray(new CacheValue[0]);
Arrays.sort(ret, (a, b) -> b.path.compareTo(a.path));
return Arrays.asList(ret);
return vals.stream().sorted((a, b) -> b.path.compareTo(a.path)).collect(Collectors.toList());
}

private boolean maybeDeferClose(CacheValue maybeDefer) {
Expand Down

0 comments on commit 1d1b47f

Please sign in to comment.