From 1a5ac2af8f802b41ad87b41ce6d8c43749b877cb Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Sun, 26 Jul 2015 23:31:22 -0700 Subject: [PATCH] Bug 1182961 (part 4, attempt 2) - Use nsTHashtable::Iterator in CacheFileHandles. r=michal. --- netwerk/cache2/CacheFileIOManager.cpp | 37 ++++++++------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index 7cfa07eaf8e..81c0eb3d763 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -427,37 +427,13 @@ CacheFileHandles::RemoveHandle(CacheFileHandle *aHandle) } } -static PLDHashOperator -GetAllHandlesEnum(CacheFileHandles::HandleHashKey* aEntry, void *aClosure) -{ - nsTArray > *array = - static_cast > *>(aClosure); - - aEntry->GetHandles(*array); - return PL_DHASH_NEXT; -} - void CacheFileHandles::GetAllHandles(nsTArray > *_retval) { MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased()); - mTable.EnumerateEntries(&GetAllHandlesEnum, _retval); -} - -static PLDHashOperator -GetActiveHandlesEnum(CacheFileHandles::HandleHashKey* aEntry, void *aClosure) -{ - nsTArray > *array = - static_cast > *>(aClosure); - - nsRefPtr handle = aEntry->GetNewestHandle(); - MOZ_ASSERT(handle); - - if (!handle->IsDoomed()) { - array->AppendElement(handle); + for (auto iter = mTable.Iter(); !iter.Done(); iter.Next()) { + iter.Get()->GetHandles(*_retval); } - - return PL_DHASH_NEXT; } void @@ -465,7 +441,14 @@ CacheFileHandles::GetActiveHandles( nsTArray > *_retval) { MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased()); - mTable.EnumerateEntries(&GetActiveHandlesEnum, _retval); + for (auto iter = mTable.Iter(); !iter.Done(); iter.Next()) { + nsRefPtr handle = iter.Get()->GetNewestHandle(); + MOZ_ASSERT(handle); + + if (!handle->IsDoomed()) { + _retval->AppendElement(handle); + } + } } void