summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorGreg Kaiser <gkaiser@google.com>2019-03-26 11:58:53 -0700
committerGreg Kaiser <gkaiser@google.com>2019-03-26 12:00:19 -0700
commite2125fdeb1f72f5599853f82fc7ed2be9d5ee015 (patch)
tree433739e6796aa6716c4f00088250b0430ad1e55d /adb
parentd2c4eb0daeb3a668e6127a9f932bf313a0840be1 (diff)
downloadsystem_core-e2125fdeb1f72f5599853f82fc7ed2be9d5ee015.tar.gz
system_core-e2125fdeb1f72f5599853f82fc7ed2be9d5ee015.tar.bz2
system_core-e2125fdeb1f72f5599853f82fc7ed2be9d5ee015.zip
adb: Avoid extra std::string copies
When a function argument takes a std::string, it's inefficient to pass std::string::c_str(), since that creates an additional copy. So we change these calling sites. Test: TreeHugger Change-Id: I1c0fde7275eb3ebd3baf05ec62581b0243655608
Diffstat (limited to 'adb')
-rw-r--r--adb/adb_utils.cpp2
-rw-r--r--adb/bugreport_test.cpp2
-rw-r--r--adb/client/auth.cpp2
-rw-r--r--adb/client/file_sync_client.cpp6
-rw-r--r--adb/daemon/file_sync_service.cpp2
-rw-r--r--adb/services.cpp2
6 files changed, 8 insertions, 8 deletions
diff --git a/adb/adb_utils.cpp b/adb/adb_utils.cpp
index 69603455a..9791769a4 100644
--- a/adb/adb_utils.cpp
+++ b/adb/adb_utils.cpp
@@ -312,7 +312,7 @@ std::string adb_get_android_dir_path() {
std::string android_dir = user_dir + OS_PATH_SEPARATOR + ".android";
struct stat buf;
if (stat(android_dir.c_str(), &buf) == -1) {
- if (adb_mkdir(android_dir.c_str(), 0750) == -1) {
+ if (adb_mkdir(android_dir, 0750) == -1) {
PLOG(FATAL) << "Cannot mkdir '" << android_dir << "'";
}
}
diff --git a/adb/bugreport_test.cpp b/adb/bugreport_test.cpp
index 72ca59aa7..a6be20368 100644
--- a/adb/bugreport_test.cpp
+++ b/adb/bugreport_test.cpp
@@ -136,7 +136,7 @@ class BugreportTest : public ::testing::Test {
void ExpectBugreportzVersion(const std::string& version) {
EXPECT_CALL(br_, SendShellCommand("bugreportz -v", false, _))
- .WillOnce(DoAll(WithArg<2>(WriteOnStderr(version.c_str())),
+ .WillOnce(DoAll(WithArg<2>(WriteOnStderr(version)),
WithArg<2>(ReturnCallbackDone(0))));
}
diff --git a/adb/client/auth.cpp b/adb/client/auth.cpp
index bcb829b1c..3eee426c8 100644
--- a/adb/client/auth.cpp
+++ b/adb/client/auth.cpp
@@ -416,7 +416,7 @@ void adb_auth_init() {
#endif
for (const std::string& path : key_paths) {
- load_keys(path.c_str());
+ load_keys(path);
}
}
diff --git a/adb/client/file_sync_client.cpp b/adb/client/file_sync_client.cpp
index 7e470e1fc..5d1023845 100644
--- a/adb/client/file_sync_client.cpp
+++ b/adb/client/file_sync_client.cpp
@@ -1012,7 +1012,7 @@ bool do_sync_push(const std::vector<const char*>& srcs, const char* dst, bool sy
dst_dir.append(android::base::Basename(src_path));
}
- success &= copy_local_dir_remote(sc, src_path, dst_dir.c_str(), sync, false);
+ success &= copy_local_dir_remote(sc, src_path, dst_dir, sync, false);
continue;
} else if (!should_push_file(st.st_mode)) {
sc.Warning("skipping special file '%s' (mode = 0o%o)", src_path, st.st_mode);
@@ -1128,7 +1128,7 @@ static bool copy_remote_dir_local(SyncConnection& sc, std::string rpath,
// Recursively build the list of files to copy.
sc.Printf("pull: building file list...");
std::vector<copyinfo> file_list;
- if (!remote_build_list(sc, &file_list, rpath.c_str(), lpath.c_str())) {
+ if (!remote_build_list(sc, &file_list, rpath, lpath)) {
return false;
}
@@ -1240,7 +1240,7 @@ bool do_sync_pull(const std::vector<const char*>& srcs, const char* dst,
dst_dir.append(android::base::Basename(src_path));
}
- success &= copy_remote_dir_local(sc, src_path, dst_dir.c_str(), copy_attrs);
+ success &= copy_remote_dir_local(sc, src_path, dst_dir, copy_attrs);
continue;
} else if (!should_pull_file(src_st.st_mode)) {
sc.Warning("skipping special file '%s' (mode = 0o%o)", src_path, src_st.st_mode);
diff --git a/adb/daemon/file_sync_service.cpp b/adb/daemon/file_sync_service.cpp
index 29bd798d4..e82a51f2b 100644
--- a/adb/daemon/file_sync_service.cpp
+++ b/adb/daemon/file_sync_service.cpp
@@ -422,7 +422,7 @@ static bool do_send(int s, const std::string& spec, std::vector<char>& buffer) {
bool result;
uint32_t timestamp;
if (S_ISLNK(mode)) {
- result = handle_send_link(s, path.c_str(), &timestamp, buffer);
+ result = handle_send_link(s, path, &timestamp, buffer);
} else {
// Copy user permission bits to "group" and "other" permissions.
mode &= 0777;
diff --git a/adb/services.cpp b/adb/services.cpp
index 80f9f7925..cf346bade 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -188,7 +188,7 @@ static void connect_service(unique_fd fd, std::string host) {
if (!strncmp(host.c_str(), "emu:", 4)) {
connect_emulator(host.c_str() + 4, &response);
} else {
- connect_device(host.c_str(), &response);
+ connect_device(host, &response);
}
// Send response for emulator and device