aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2016-11-01 14:49:08 -0700
committerDan Willemsen <dwillemsen@google.com>2016-11-01 14:49:46 -0700
commitcb2ff8558ced3ddc021823a3c86bc7ce02dcbdc3 (patch)
treea1c65ac2a0f2ef41fbb29ea16c27f1ad5ccdc2d4
parentba9de4bc7eb7327d1177270d0956d6cb7aaf1d9c (diff)
Fix some possible performance issues found by clang-tidy
No obvious time differences when building AOSP, but these all seem like reasonable changes.
-rw-r--r--Android.bp5
-rw-r--r--dep.cc2
-rw-r--r--rule.cc2
-rw-r--r--rule.h2
-rw-r--r--strutil.cc2
-rw-r--r--strutil.h2
6 files changed, 10 insertions, 5 deletions
diff --git a/Android.bp b/Android.bp
index f95b366..8dbb9cb 100644
--- a/Android.bp
+++ b/Android.bp
@@ -25,6 +25,11 @@ cc_defaults {
host_ldlibs: ["-lrt", "-lpthread"],
},
},
+ tidy_checks: [
+ "-google-global-names-in-headers",
+ "-google-build-using-namespace",
+ "-google-explicit-constructor",
+ ],
}
cc_library_host_static {
diff --git a/dep.cc b/dep.cc
index 502ec47..4bdf9ab 100644
--- a/dep.cc
+++ b/dep.cc
@@ -534,7 +534,7 @@ class DepBuilder {
if (found == suffix_rules_.end())
return rule_merger;
- for (shared_ptr<Rule> irule : found->second) {
+ for (const shared_ptr<Rule> &irule : found->second) {
CHECK(irule->inputs.size() == 1);
Symbol input = ReplaceSuffix(output, irule->inputs[0]);
if (!Exists(input))
diff --git a/rule.cc b/rule.cc
index 68ec7f5..6942fb5 100644
--- a/rule.cc
+++ b/rule.cc
@@ -54,7 +54,7 @@ Rule::Rule()
}
void ParseRule(Loc& loc, StringPiece line, char term,
- function<string()> after_term_fn,
+ const function<string()> &after_term_fn,
Rule** out_rule, RuleVarAssignment* rule_var) {
size_t index = line.find(':');
if (index == string::npos) {
diff --git a/rule.h b/rule.h
index 4d72bb7..84412c1 100644
--- a/rule.h
+++ b/rule.h
@@ -65,7 +65,7 @@ struct RuleVarAssignment {
// |term| is '='), |after_term_fn| will be called to obtain the right
// hand side.
void ParseRule(Loc& loc, StringPiece line, char term,
- function<string()> after_term_fn,
+ const function<string()> &after_term_fn,
Rule** rule, RuleVarAssignment* rule_var);
#endif // RULE_H_
diff --git a/strutil.cc b/strutil.cc
index 1b99dff..b094198 100644
--- a/strutil.cc
+++ b/strutil.cc
@@ -500,7 +500,7 @@ string ConcatDir(StringPiece b, StringPiece n) {
return r;
}
-string EchoEscape(const string str) {
+string EchoEscape(const string &str) {
const char *in = str.c_str();
string buf;
for (; *in; in++) {
diff --git a/strutil.h b/strutil.h
index 12e46a5..d61160d 100644
--- a/strutil.h
+++ b/strutil.h
@@ -140,7 +140,7 @@ string SortWordsInString(StringPiece s);
string ConcatDir(StringPiece b, StringPiece n);
-string EchoEscape(const string str);
+string EchoEscape(const string &str);
void EscapeShell(string* s);