From: David ‘Bombe’ Roden Date: Tue, 21 Jan 2014 06:22:42 +0000 (+0100) Subject: Only create the search parameters once per search. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=1ce00a4e7098a4c1dc84718bf4e1a6d6a153f0c6;p=xudocci.git Only create the search parameters once per search. --- diff --git a/src/main/java/net/pterodactylus/xdcc/ui/stdin/SearchCommand.java b/src/main/java/net/pterodactylus/xdcc/ui/stdin/SearchCommand.java index 170365a..0ae1b15 100644 --- a/src/main/java/net/pterodactylus/xdcc/ui/stdin/SearchCommand.java +++ b/src/main/java/net/pterodactylus/xdcc/ui/stdin/SearchCommand.java @@ -22,6 +22,7 @@ import static java.util.Arrays.asList; import static java.util.regex.Pattern.CASE_INSENSITIVE; import static java.util.regex.Pattern.UNICODE_CASE; import static java.util.regex.Pattern.compile; +import static java.util.stream.Collectors.toList; import java.io.IOException; import java.io.Writer; @@ -72,9 +73,10 @@ public class SearchCommand implements Command { @Override public State execute(State state, List parameters, Writer outputWriter) throws IOException { List lastResult = newArrayList(); + List searchParameters = parameters.stream().map(SearchParameter::from).collect(toList()); for (Bot bot : newArrayList(core.bots())) { for (Pack pack : newArrayList(bot)) { - if (parameters.stream().map(SearchParameter::from).allMatch((parameter) -> parameter.matches(pack.name()))) { + if (searchParameters.stream().allMatch((parameter) -> parameter.matches(pack.name()))) { lastResult.add(new Result(core, bot, pack)); } }