From 23abfd37a55f281186f9275ad35b7182efd2e8b6 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Wed, 27 Jul 2016 10:19:47 -0700 Subject: Fix clang-tidy performance warnings. * Use const reference parameter type to avoid unnecessary copy. * Use more efficient overloaded string methods. Bug: 30407689 Bug: 30411878 Change-Id: Iefab05c077367f272abf545036b853e8a295c8cd Test: build with WITH_TIDY=1 --- minui/events.cpp | 2 +- minui/minui.h | 2 +- otafault/ota_io.cpp | 2 +- recovery-refresh.cpp | 2 +- recovery.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/minui/events.cpp b/minui/events.cpp index a6b9671ed..e6e7bd28c 100644 --- a/minui/events.cpp +++ b/minui/events.cpp @@ -204,7 +204,7 @@ int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data) { return 0; } -void ev_iterate_available_keys(std::function f) { +void ev_iterate_available_keys(const std::function& f) { // Use unsigned long to match ioctl's parameter type. unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; // NOLINT unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)]; // NOLINT diff --git a/minui/minui.h b/minui/minui.h index e3bc00548..b2648fb33 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -67,7 +67,7 @@ typedef int (*ev_set_key_callback)(int code, int value, void* data); int ev_init(ev_callback input_cb, void* data); void ev_exit(); int ev_add_fd(int fd, ev_callback cb, void* data); -void ev_iterate_available_keys(std::function f); +void ev_iterate_available_keys(const std::function& f); int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data); // 'timeout' has the same semantics as poll(2). diff --git a/otafault/ota_io.cpp b/otafault/ota_io.cpp index dd805e56e..cb37d515a 100644 --- a/otafault/ota_io.cpp +++ b/otafault/ota_io.cpp @@ -31,7 +31,7 @@ static std::string write_fault_file_name = ""; static std::string fsync_fault_file_name = ""; bool have_eio_error = false; -static bool get_hit_file(const char* cached_path, std::string ffn) { +static bool get_hit_file(const char* cached_path, const std::string& ffn) { return should_hit_cache() ? !strncmp(cached_path, OTAIO_CACHE_FNAME, strlen(cached_path)) : !strncmp(cached_path, ffn.c_str(), strlen(cached_path)); diff --git a/recovery-refresh.cpp b/recovery-refresh.cpp index 333367eba..b75c91538 100644 --- a/recovery-refresh.cpp +++ b/recovery-refresh.cpp @@ -76,7 +76,7 @@ static ssize_t logrotate( } std::string name(filename); - size_t dot = name.find_last_of("."); + size_t dot = name.find_last_of('.'); std::string sub = name.substr(0, dot); if (!strstr(LAST_KMSG_FILE, sub.c_str()) && diff --git a/recovery.cpp b/recovery.cpp index b4dc41bfa..28dd212ba 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -1274,7 +1274,7 @@ static ssize_t logrotate( } std::string name(filename); - size_t dot = name.find_last_of("."); + size_t dot = name.find_last_of('.'); std::string sub = name.substr(0, dot); if (!strstr(LAST_KMSG_FILE, sub.c_str()) && -- cgit v1.2.3