mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 1693541 - Improve uses of nsBaseHashtable and descendants and avoid multiple subsequent lookups in security/manager/ssl/DataStorage.cpp. r=keeler
Differential Revision: https://phabricator.services.mozilla.com/D106102
This commit is contained in:
parent
d2cf2fa5cc
commit
2a40dba629
@ -111,12 +111,8 @@ already_AddRefed<DataStorage> DataStorage::GetFromRawFileName(
|
||||
sDataStorages = new DataStorages();
|
||||
ClearOnShutdown(&sDataStorages);
|
||||
}
|
||||
RefPtr<DataStorage> storage;
|
||||
if (!sDataStorages->Get(aFilename, getter_AddRefs(storage))) {
|
||||
storage = new DataStorage(aFilename);
|
||||
sDataStorages->InsertOrUpdate(aFilename, RefPtr{storage});
|
||||
}
|
||||
return storage.forget();
|
||||
return do_AddRef(sDataStorages->LookupOrInsertWith(
|
||||
aFilename, [&] { return RefPtr{new DataStorage(aFilename)}; }));
|
||||
}
|
||||
|
||||
// static
|
||||
@ -482,11 +478,8 @@ DataStorage::Reader::Run() {
|
||||
if (NS_SUCCEEDED(parseRV)) {
|
||||
// It could be the case that a newer entry was added before
|
||||
// we got around to reading the file. Don't overwrite new entries.
|
||||
Entry newerEntry;
|
||||
bool present = mDataStorage->mPersistentDataTable.Get(key, &newerEntry);
|
||||
if (!present) {
|
||||
mDataStorage->mPersistentDataTable.InsertOrUpdate(key, entry);
|
||||
}
|
||||
mDataStorage->mPersistentDataTable.LookupOrInsert(key,
|
||||
std::move(entry));
|
||||
}
|
||||
} while (true);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user