Avoid string copies in OverlayUserPrefStore.
Bug: 349741884 Change-Id: Iab74393bcb4ec85d658b79924d081d7399844599 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5667397 Commit-Queue: Jan Keitel <jkeitel@google.com> Reviewed-by: Dominic Battré <battre@chromium.org> Cr-Commit-Position: refs/heads/main@{#1320954}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
df42fc8339
commit
07b772bdff
components/prefs
@ -26,9 +26,7 @@ class OverlayUserPrefStore::ObserverAdapter : public PrefStore::Observer {
|
||||
|
||||
// Methods of PrefStore::Observer.
|
||||
void OnPrefValueChanged(std::string_view key) override {
|
||||
// TODO: crbug.com/349741884 - Pass `std::string_view` once the interface is
|
||||
// changed.
|
||||
parent_->OnPrefValueChanged(ephemeral_user_pref_store_, std::string(key));
|
||||
parent_->OnPrefValueChanged(ephemeral_user_pref_store_, key);
|
||||
}
|
||||
void OnInitializationCompleted(bool succeeded) override {
|
||||
parent_->OnInitializationCompleted(ephemeral_user_pref_store_, succeeded);
|
||||
@ -225,7 +223,7 @@ OverlayUserPrefStore::~OverlayUserPrefStore() {
|
||||
}
|
||||
|
||||
void OverlayUserPrefStore::OnPrefValueChanged(bool ephemeral,
|
||||
const std::string& key) {
|
||||
std::string_view key) {
|
||||
if (ephemeral) {
|
||||
ReportValueChanged(key, DEFAULT_PREF_WRITE_FLAGS);
|
||||
} else {
|
||||
|
@ -81,7 +81,7 @@ class COMPONENTS_PREFS_EXPORT OverlayUserPrefStore
|
||||
private:
|
||||
class ObserverAdapter;
|
||||
|
||||
void OnPrefValueChanged(bool ephemeral, const std::string& key);
|
||||
void OnPrefValueChanged(bool ephemeral, std::string_view key);
|
||||
void OnInitializationCompleted(bool ephemeral, bool succeeded);
|
||||
|
||||
// Returns true if |key| corresponds to a preference that shall be stored in
|
||||
|
Reference in New Issue
Block a user