Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d968f038 authored by Greg Kaiser's avatar Greg Kaiser Committed by Martin Brabham
Browse files

[DO NOT MERGE] btif: Avoid a couple string copies

We pass a couple string arguments by const reference instead of
by copy.

Bug: b/117993149
Test: TreeHugger
Change-Id: I01e476edf1f5e8c7b6fc88e0eb87ed3bbfca7a00
Merged-In: I01e476edf1f5e8c7b6fc88e0eb87ed3bbfca7a00
parent 92542d13
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -82,9 +82,9 @@ static std::unique_ptr<config_t> btif_config_open(const char* filename, const ch
// Key attestation
static std::string hash_file(const char* filename);
static std::string read_checksum_file(const char* filename);
static void write_checksum_file(const char* filename, const std::string hash);
static bool verify_hash(const std::string current_hash,
                        const std::string stored_hash);
static void write_checksum_file(const char* filename, const std::string& hash);
static bool verify_hash(const std::string& current_hash,
                        const std::string& stored_hash);

static enum ConfigSource {
  NOT_LOADED,
@@ -611,13 +611,15 @@ static std::string read_checksum_file(const char* checksum_filename) {
  return output;
}

static void write_checksum_file(const char* checksum_filename, std::string hash) {
static void write_checksum_file(const char* checksum_filename,
                                const std::string& hash) {
  int result = btifKeystore.Encrypt(hash, checksum_filename, 0);
  if (result != 0) {
    LOG(ERROR) << "Failed writing checksum!";
  }
}

static bool verify_hash(std::string current_hash, std::string stored_hash) {
static bool verify_hash(const std::string& current_hash,
                        const std::string& stored_hash) {
  return current_hash.compare(stored_hash) == 0;
}