diff options
| author | Dan Willemsen <dwillemsen@google.com> | 2018-02-05 20:58:09 -0800 |
|---|---|---|
| committer | Dan Willemsen <dwillemsen@google.com> | 2018-02-06 14:55:03 -0800 |
| commit | 23fa84358587eee87a45ff41f7559512c4549fb0 (patch) | |
| tree | c792785956a8981d32179c0a028586234c5dc229 | |
| parent | 4c6ff1826c53f5b260903321548e286296cbd8f5 (diff) | |
| download | platform_build_kati-23fa84358587eee87a45ff41f7559512c4549fb0.tar.gz platform_build_kati-23fa84358587eee87a45ff41f7559512c4549fb0.tar.bz2 platform_build_kati-23fa84358587eee87a45ff41f7559512c4549fb0.zip | |
Support the implicit "-a" in find
The find man page says that "expression expression" is equivalent to
"expression -a expression".
This reduces the number of shell commands we need to run during regen
check of one of the internal android trees by ~10%, which reduced the
time spent in regen checking by ~60%.
before: *kati*: shell time (regen): 5.842119 / 516
after: *kati*: shell time (regen): 2.377083 / 462
Change-Id: I177f37cd7e12625fb2dbfa371f3d79cb625c84fe
| -rw-r--r-- | find.cc | 16 | ||||
| -rw-r--r-- | testcase/find_command.mk | 1 |
2 files changed, 11 insertions, 6 deletions
@@ -526,12 +526,16 @@ class FindCommandParser { while (true) { if (!GetNextToken(&tok)) return NULL; - if (tok != "-and" && tok != "-a") { - UngetToken(tok); - return c.release(); + if (tok == "-and" || tok == "-a") { + if (!GetNextToken(&tok) || tok.empty()) + return NULL; + } else { + if (tok != "-not" && tok != "\\!" && tok != "\\(" && tok != "-name" && + tok != "-type") { + UngetToken(tok); + return c.release(); + } } - if (!GetNextToken(&tok) || tok.empty()) - return NULL; unique_ptr<FindCond> r(ParseFact(tok)); if (!r.get()) { return NULL; @@ -562,7 +566,7 @@ class FindCommandParser { } // <expr> ::= <term> {<or> <term>} - // <term> ::= <fact> {<and> <fact>} + // <term> ::= <fact> {[<and>] <fact>} // <fact> ::= <not> <fact> | '\(' <expr> '\)' | <pred> // <not> ::= '-not' | '\!' // <and> ::= '-and' | '-a' diff --git a/testcase/find_command.mk b/testcase/find_command.mk index c3e8a07..b714879 100644 --- a/testcase/find_command.mk +++ b/testcase/find_command.mk @@ -67,6 +67,7 @@ endif $(call run_find, find testdir -name "file1") $(call run_find, find testdir -name "file1") $(call run_find, find testdir -name "*1") + $(call run_find, find testdir -name "*1" -name "file*") $(call run_find, find testdir -name "*1" -and -name "file*") $(call run_find, find testdir -name "*1" -or -name "file*") $(call run_find, find testdir -name "*1" -or -type f) |
