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

Commit 92bc679e authored by Greg Kaiser's avatar Greg Kaiser
Browse files

btif: Avoid a couple string copies

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

Test: TreeHugger
Change-Id: I01e476edf1f5e8c7b6fc88e0eb87ed3bbfca7a00
parent 33100512
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -87,9 +87,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,
@@ -675,13 +675,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;
}