diff options
author | Chih-Hung Hsieh <chh@google.com> | 2016-07-27 15:22:01 -0700 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2016-07-27 17:58:57 -0700 |
commit | a2b490908d03d77d3f385e86b24c929555bb79d5 (patch) | |
tree | 7ca6c7fd136d0a8f70191d8ed265f89bdb647e45 /simpleperf/cmd_report_test.cpp | |
parent | cab924fae5ec24da5b62b1f7253c772ab51031e2 (diff) | |
download | extras-a2b490908d03d77d3f385e86b24c929555bb79d5.tar.gz |
Fix clang-tidy performance warnings in simpleperf.
* Use const reference type for parameters to avoid unnecessary copy.
* Use faster overloaded string find function.
Bug: 30407689
Bug: 30411878
Change-Id: I2dac3ab1928fd51fe03c4d7889f17f3b165918f3
Test: build with WITH_TIDY=1
Diffstat (limited to 'simpleperf/cmd_report_test.cpp')
-rw-r--r-- | simpleperf/cmd_report_test.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp index e0b35bf0..0dbf7795 100644 --- a/simpleperf/cmd_report_test.cpp +++ b/simpleperf/cmd_report_test.cpp @@ -37,13 +37,13 @@ static std::unique_ptr<Command> ReportCmd() { class ReportCommandTest : public ::testing::Test { protected: void Report( - const std::string perf_data, + const std::string& perf_data, const std::vector<std::string>& add_args = std::vector<std::string>()) { ReportRaw(GetTestData(perf_data), add_args); } void ReportRaw( - const std::string perf_data, + const std::string& perf_data, const std::vector<std::string>& add_args = std::vector<std::string>()) { success = false; std::vector<std::string> args = { @@ -134,7 +134,7 @@ static bool CheckCalleeMode(std::vector<std::string>& lines) { bool found = false; for (size_t i = 0; i + 2 < lines.size(); ++i) { if (lines[i].find("GlobalFunc") != std::string::npos && - lines[i + 1].find("|") != std::string::npos && + lines[i + 1].find('|') != std::string::npos && lines[i + 2].find("main") != std::string::npos) { found = true; break; @@ -147,7 +147,7 @@ static bool CheckCallerMode(std::vector<std::string>& lines) { bool found = false; for (size_t i = 0; i + 2 < lines.size(); ++i) { if (lines[i].find("main") != std::string::npos && - lines[i + 1].find("|") != std::string::npos && + lines[i + 1].find('|') != std::string::npos && lines[i + 2].find("GlobalFunc") != std::string::npos) { found = true; break; |