Skip to content

Commit

Permalink
Cleanup: Pass std::string as const reference from rlz/
Browse files Browse the repository at this point in the history
Passing std::string by reference can prevent extra copying of object.

BUG=367418
TEST=
R=rogerta@chromium.org,thakis@chromium.org

Review URL: https://codereview.chromium.org/1353323003

Cr-Commit-Position: refs/heads/master@{#349885}
  • Loading branch information
k15tfu authored and Commit bot committed Sep 20, 2015
1 parent bfacce0 commit 116c750
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions rlz/chromeos/lib/rlz_value_store_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ base::FilePath GetRlzStoreLockPath() {
}

// Returns the dictionary key for storing access point-related prefs.
std::string GetKeyName(std::string key, AccessPoint access_point) {
std::string GetKeyName(const std::string& key, AccessPoint access_point) {
std::string brand = SupplementaryBranding::GetBrand();
if (brand.empty())
brand = kNoSupplementaryBrand;
return key + "." + GetAccessPointName(access_point) + "." + brand;
}

// Returns the dictionary key for storing product-related prefs.
std::string GetKeyName(std::string key, Product product) {
std::string GetKeyName(const std::string& key, Product product) {
std::string brand = SupplementaryBranding::GetBrand();
if (brand.empty())
brand = kNoSupplementaryBrand;
Expand Down Expand Up @@ -242,7 +242,7 @@ void RlzValueStoreChromeOS::WriteStore() {
LOG(ERROR) << "Error writing RLZ store";
}

bool RlzValueStoreChromeOS::AddValueToList(std::string list_name,
bool RlzValueStoreChromeOS::AddValueToList(const std::string& list_name,
base::Value* value) {
base::ListValue* list_value = NULL;
if (!rlz_store_->GetList(list_name, &list_value)) {
Expand All @@ -253,7 +253,7 @@ bool RlzValueStoreChromeOS::AddValueToList(std::string list_name,
return true;
}

bool RlzValueStoreChromeOS::RemoveValueFromList(std::string list_name,
bool RlzValueStoreChromeOS::RemoveValueFromList(const std::string& list_name,
const base::Value& value) {
base::ListValue* list_value = NULL;
if (!rlz_store_->GetList(list_name, &list_value))
Expand Down
5 changes: 3 additions & 2 deletions rlz/chromeos/lib/rlz_value_store_chromeos.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ class RlzValueStoreChromeOS : public RlzValueStore,
void WriteStore();

// Adds |value| to list at |list_name| path in JSON store.
bool AddValueToList(std::string list_name, base::Value* value);
bool AddValueToList(const std::string& list_name, base::Value* value);
// Removes |value| from list at |list_name| path in JSON store.
bool RemoveValueFromList(std::string list_name, const base::Value& value);
bool RemoveValueFromList(const std::string& list_name,
const base::Value& value);

// In-memory store with RLZ data.
scoped_ptr<base::DictionaryValue> rlz_store_;
Expand Down

0 comments on commit 116c750

Please sign in to comment.