]> git.lizzy.rs Git - rust.git/commitdiff
Don't allocate args in order to run find.
authorMark Simulacrum <mark.simulacrum@gmail.com>
Wed, 21 Jun 2017 17:15:49 +0000 (11:15 -0600)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Tue, 4 Jul 2017 13:31:55 +0000 (07:31 -0600)
src/bootstrap/flags.rs

index dc9dac73627880b864916fc24816c3a23fd185b5..cb455ca6a14e5cd93c00d80f2af23f6e16b8a20a 100644 (file)
@@ -122,16 +122,15 @@ pub fn parse(args: &[String]) -> Flags {
         // the subcommand. Therefore we must manually identify the subcommand first, so that we can
         // complete the definition of the options.  Then we can use the getopt::Matches object from
         // there on out.
-        let mut possible_subcommands = args.iter().collect::<Vec<_>>();
-        possible_subcommands.retain(|&s|
-                                           (s == "build")
-                                        || (s == "test")
-                                        || (s == "bench")
-                                        || (s == "doc")
-                                        || (s == "clean")
-                                        || (s == "dist")
-                                        || (s == "install"));
-        let subcommand = match possible_subcommands.first() {
+        let subcommand = args.iter().find(|&s|
+            (s == "build")
+            || (s == "test")
+            || (s == "bench")
+            || (s == "doc")
+            || (s == "clean")
+            || (s == "dist")
+            || (s == "install"));
+        let subcommand = match subcommand {
             Some(s) => s,
             None => {
                 // No subcommand -- show the general usage and subcommand help