зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1184468 - Use nsTHashtable::Keys where possible in netwerk. r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D106950
This commit is contained in:
Родитель
5b5b39393f
Коммит
15d3d060cf
|
@ -255,14 +255,14 @@ class WalkMemoryCacheRunnable : public WalkCacheRunnable {
|
|||
|
||||
if (!CacheStorageService::IsRunning()) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
for (auto iterGlobal = sGlobalEntryTables->Iter(); !iterGlobal.Done();
|
||||
iterGlobal.Next()) {
|
||||
for (auto iterGlobal = sGlobalEntryTables->ConstIter();
|
||||
!iterGlobal.Done(); iterGlobal.Next()) {
|
||||
CacheEntryTable* entries = iterGlobal.UserData();
|
||||
if (entries->Type() != CacheEntryTable::MEMORY_ONLY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto iter = entries->Iter(); !iter.Done(); iter.Next()) {
|
||||
for (auto iter = entries->ConstIter(); !iter.Done(); iter.Next()) {
|
||||
CacheEntry* entry = iter.UserData();
|
||||
|
||||
MOZ_ASSERT(!entry->IsUsingDisk());
|
||||
|
@ -545,8 +545,7 @@ void CacheStorageService::DropPrivateBrowsingEntries() {
|
|||
if (mShutdown) return;
|
||||
|
||||
nsTArray<nsCString> keys;
|
||||
for (auto iter = sGlobalEntryTables->Iter(); !iter.Done(); iter.Next()) {
|
||||
const nsACString& key = iter.Key();
|
||||
for (const nsACString& key : sGlobalEntryTables->Keys()) {
|
||||
nsCOMPtr<nsILoadContextInfo> info = CacheFileUtils::ParseKey(key);
|
||||
if (info && info->IsPrivate()) {
|
||||
keys.AppendElement(key);
|
||||
|
@ -801,13 +800,9 @@ NS_IMETHODIMP CacheStorageService::Clear() {
|
|||
|
||||
NS_ENSURE_TRUE(!mShutdown, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsTArray<nsCString> keys;
|
||||
for (auto iter = sGlobalEntryTables->Iter(); !iter.Done(); iter.Next()) {
|
||||
keys.AppendElement(iter.Key());
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < keys.Length(); ++i) {
|
||||
DoomStorageEntries(keys[i], nullptr, true, false, nullptr);
|
||||
const auto keys = ToTArray<nsTArray<nsCString>>(sGlobalEntryTables->Keys());
|
||||
for (const auto& key : keys) {
|
||||
DoomStorageEntries(key, nullptr, true, false, nullptr);
|
||||
}
|
||||
|
||||
// Passing null as a load info means to evict all contexts.
|
||||
|
@ -904,7 +899,7 @@ nsresult CacheStorageService::ClearOriginInternal(
|
|||
|
||||
nsTArray<RefPtr<CacheEntry>> entriesToDelete;
|
||||
|
||||
for (auto entryIter = table->Iter(); !entryIter.Done();
|
||||
for (auto entryIter = table->ConstIter(); !entryIter.Done();
|
||||
entryIter.Next()) {
|
||||
CacheEntry* entry = entryIter.UserData();
|
||||
|
||||
|
|
|
@ -208,9 +208,7 @@ void nsHttpAuthCache::ClearOriginData(OriginAttributesPattern const& pattern) {
|
|||
}
|
||||
|
||||
void nsHttpAuthCache::CollectKeys(nsTArray<nsCString>& aValue) {
|
||||
for (auto iter = mDB.Iter(); !iter.Done(); iter.Next()) {
|
||||
aValue.AppendElement(iter.Key());
|
||||
}
|
||||
AppendToArray(aValue, mDB.Keys());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -3286,6 +3286,18 @@ auto ToArray(const Range& aRange) {
|
|||
aRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements from a range to an array.
|
||||
*/
|
||||
template <typename Array, typename Range>
|
||||
void AppendToArray(Array& aArray, const Range& aRange) {
|
||||
using std::begin;
|
||||
using std::end;
|
||||
|
||||
aArray.SetCapacity(aArray.Length() + RangeSize(aRange));
|
||||
std::copy(begin(aRange), end(aRange), MakeBackInserter(aArray));
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
// MOZ_DBG support
|
||||
|
|
Загрузка…
Ссылка в новой задаче