Commit aee53e9e authored by vabr's avatar vabr Committed by Commit bot

country_names.cc: SetLocaleString takes const ref

SetLocaleString took a string by value and used std::move on it.

After a discussion on chromium-dev [1], pasing a const ref was recognised as
the preferred style in Chromium, so this CL changes it.

[1]
https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-dev/string$20const$20ref/chromium-dev/ZoAfW7GXUVI/fCYjkg2JBAAJ

BUG=571610
R=isherman@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#371617}
parent f609f72d
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "components/autofill/core/browser/country_names.h" #include "components/autofill/core/browser/country_names.h"
#include <stdint.h> #include <stdint.h>
#include <utility>
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -142,13 +141,13 @@ CountryNames* CountryNames::GetInstance() { ...@@ -142,13 +141,13 @@ CountryNames* CountryNames::GetInstance() {
} }
// static // static
void CountryNames::SetLocaleString(std::string locale) { void CountryNames::SetLocaleString(const std::string& locale) {
DCHECK(!locale.empty()); DCHECK(!locale.empty());
// Application locale should never be empty. The empty value of // Application locale should never be empty. The empty value of
// |g_application_locale| means that it has not been initialized yet. // |g_application_locale| means that it has not been initialized yet.
std::string* storage = g_application_locale.Pointer(); std::string* storage = g_application_locale.Pointer();
if (storage->empty()) { if (storage->empty()) {
*storage = std::move(locale); *storage = locale;
} }
// TODO(crbug.com/579971) CountryNames currently cannot adapt to changed // TODO(crbug.com/579971) CountryNames currently cannot adapt to changed
// locale without Chrome's restart. // locale without Chrome's restart.
......
...@@ -33,7 +33,7 @@ class CountryNames { ...@@ -33,7 +33,7 @@ class CountryNames {
// Tells CountryNames, what is the application locale. Only the first supplied // Tells CountryNames, what is the application locale. Only the first supplied
// value is used, further calls result in no changes. Call this on the UI // value is used, further calls result in no changes. Call this on the UI
// thread, before first using CountryNames. |locale| must not be empty. // thread, before first using CountryNames. |locale| must not be empty.
static void SetLocaleString(std::string locale); static void SetLocaleString(const std::string& locale);
// Returns the country code corresponding to |country|, which should be a // Returns the country code corresponding to |country|, which should be a
// country code or country name localized to |locale_name|. // country code or country name localized to |locale_name|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment