OSDN Git Service

btif_storage: Avoid extra std::string copies
authorGreg Kaiser <gkaiser@google.com>
Tue, 26 Mar 2019 16:09:28 +0000 (09:09 -0700)
committerGreg Kaiser <gkaiser@google.com>
Tue, 2 Apr 2019 13:12:30 +0000 (06:12 -0700)
When a function takes a const std::string reference for an
argument, it's inefficient to pass in std::string::c_str().

Test: TreeHugger
Change-Id: Ibd00c10a08ab853875fd16739bce5851f6b42639

btif/src/btif_storage.cc

index 4216dbf..d4cee12 100644 (file)
@@ -486,8 +486,7 @@ static bt_status_t btif_in_fetch_bonded_devices(
         bt_linkkey_file_found = false;
       }
     }
-    if (!btif_in_fetch_bonded_ble_device(name.c_str(), add, p_bonded_devices) &&
-        !bt_linkkey_file_found) {
+    if (!btif_in_fetch_bonded_ble_device(name, add, p_bonded_devices) && !bt_linkkey_file_found) {
       BTIF_TRACE_DEBUG("Remote device:%s, no link key or ble key found",
                        name.c_str());
     }
@@ -1484,7 +1483,7 @@ void btif_storage_load_bonded_hearing_aids() {
     if (!btif_config_get_int(name, HEARING_AID_PSM, &value)) continue;
     uint16_t psm = value;
 
-    if (btif_in_fetch_bonded_device(name.c_str()) != BT_STATUS_SUCCESS) {
+    if (btif_in_fetch_bonded_device(name) != BT_STATUS_SUCCESS) {
       RawAddress bd_addr;
       RawAddress::FromString(name, bd_addr);
       btif_storage_remove_hearing_aid(bd_addr);