зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1688833 - Migrate LookupForAdd to WithEntryHandle in dom/localstorage. r=dom-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D104194
This commit is contained in:
Родитель
b2d872c3b8
Коммит
4b754c2bfa
|
@ -5435,8 +5435,8 @@ void Snapshot::SaveItem(const nsAString& aKey, const LSValue& aOldValue,
|
|||
}
|
||||
|
||||
if (!mLoadedItems.GetEntry(aKey) && !mUnknownItems.GetEntry(aKey)) {
|
||||
LSValue oldValue(aOldValue);
|
||||
mValues.LookupForAdd(aKey).OrInsert([oldValue]() { return oldValue; });
|
||||
mValues.WithEntryHandle(aKey,
|
||||
[&](auto&& entry) { entry.OrInsert(aOldValue); });
|
||||
}
|
||||
|
||||
if (aAffectsOrder && !mSavedKeys) {
|
||||
|
|
|
@ -731,14 +731,14 @@ nsresult LSSnapshot::GetItemInternal(const nsAString& aKey,
|
|||
if (aValue.WasPassed()) {
|
||||
const nsString& value = aValue.Value();
|
||||
if (!value.IsVoid()) {
|
||||
auto entry = mValues.LookupForAdd(aKey);
|
||||
if (entry) {
|
||||
result = entry.Data();
|
||||
entry.Data() = value;
|
||||
} else {
|
||||
result.SetIsVoid(true);
|
||||
entry.OrInsert([value]() { return value; });
|
||||
}
|
||||
mValues.WithEntryHandle(aKey, [&](auto&& entry) {
|
||||
if (entry) {
|
||||
result = std::exchange(entry.Data(), value);
|
||||
} else {
|
||||
result.SetIsVoid(true);
|
||||
entry.Insert(value);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (auto entry = mValues.Lookup(aKey)) {
|
||||
result = entry.Data();
|
||||
|
|
Загрузка…
Ссылка в новой задаче