Fix clang-tidy performance warnings in syste/core.
* Use const reference type for parameters to avoid unnecessary copy.
* Suppress warning of not using faster overloaded string find function.
Bug: 30407689
Bug: 30411878
Change-Id: Ie79dbe21899867bc62031f8618bb1322b8071525
Test: build with WITH_TIDY=1
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 5dde490..314ed42 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -969,7 +969,7 @@
}
static void do_for_partition(Transport* transport, const std::string& part, const std::string& slot,
- std::function<void(const std::string&)> func, bool force_slot) {
+ const std::function<void(const std::string&)>& func, bool force_slot) {
std::string has_slot;
std::string current_slot;
@@ -1002,7 +1002,7 @@
* partition does not support slots.
*/
static void do_for_partitions(Transport* transport, const std::string& part, const std::string& slot,
- std::function<void(const std::string&)> func, bool force_slot) {
+ const std::function<void(const std::string&)>& func, bool force_slot) {
std::string has_slot;
if (slot == "all") {
diff --git a/fastboot/socket_test.cpp b/fastboot/socket_test.cpp
index affbdfd..373abc3 100644
--- a/fastboot/socket_test.cpp
+++ b/fastboot/socket_test.cpp
@@ -34,7 +34,7 @@
// Creates connected sockets |server| and |client|. Returns true on success.
bool MakeConnectedSockets(Socket::Protocol protocol, std::unique_ptr<Socket>* server,
std::unique_ptr<Socket>* client,
- const std::string hostname = "localhost") {
+ const std::string& hostname = "localhost") {
*server = Socket::NewServer(protocol, 0);
if (*server == nullptr) {
ADD_FAILURE() << "Failed to create server.";