Bug 1182408 - Part 1: Move permission key checks out of loop. r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Tue, 14 Jul 2015 10:53:12 -0700
changeset 253095 f7eb7bc6a99c8a2fea9f455a8221f9bf80d673b5
parent 253094 dabb386000f889f74eb033f3825d88cbc768380a
child 253096 2c709a5c7aff60fdfd39dede4bbcbf14df9d2495
push id29061
push userryanvm@gmail.com
push dateThu, 16 Jul 2015 18:53:45 +0000
treeherdermozilla-central@a0f4a688433d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1182408
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1182408 - Part 1: Move permission key checks out of loop. r=ehsan
extensions/cookie/nsPermissionManager.cpp
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -1598,25 +1598,23 @@ nsPermissionManager::RemoveAllModifiedSi
   ImportDefaults();
   return NS_OK;
 }
 
 PLDHashOperator
 nsPermissionManager::GetPermissionsForApp(nsPermissionManager::PermissionHashKey* entry, void* arg)
 {
   GetPermissionsForAppStruct* data = static_cast<GetPermissionsForAppStruct*>(arg);
+  if (entry->GetKey()->mAppId != data->appId ||
+      (data->browserOnly && !entry->GetKey()->mIsInBrowserElement)) {
+    return PL_DHASH_NEXT;
+  }
 
   for (uint32_t i = 0; i < entry->GetPermissions().Length(); ++i) {
     nsPermissionManager::PermissionEntry& permEntry = entry->GetPermissions()[i];
-
-    if (entry->GetKey()->mAppId != data->appId ||
-        (data->browserOnly && !entry->GetKey()->mIsInBrowserElement)) {
-      continue;
-    }
-
     data->permissions.AppendObject(new nsPermission(entry->GetKey()->mHost,
                                                     entry->GetKey()->mAppId,
                                                     entry->GetKey()->mIsInBrowserElement,
                                                     gPermissionManager->mTypeArray.ElementAt(permEntry.mType),
                                                     permEntry.mPermission,
                                                     permEntry.mExpireType,
                                                     permEntry.mExpireTime));
   }
@@ -1687,22 +1685,21 @@ nsPermissionManager::RemovePermissionsFo
   return NS_OK;
 }
 
 PLDHashOperator
 nsPermissionManager::RemoveExpiredPermissionsForAppEnumerator(
   nsPermissionManager::PermissionHashKey* entry, void* arg)
 {
   uint32_t* appId = static_cast<uint32_t*>(arg);
+  if (entry->GetKey()->mAppId != *appId) {
+    return PL_DHASH_NEXT;
+  }
 
   for (uint32_t i = 0; i < entry->GetPermissions().Length(); ++i) {
-    if (entry->GetKey()->mAppId != *appId) {
-      continue;
-    }
-
     nsPermissionManager::PermissionEntry& permEntry = entry->GetPermissions()[i];
     if (permEntry.mExpireType != nsIPermissionManager::EXPIRE_SESSION) {
       continue;
     }
 
     if (permEntry.mNonSessionExpireType == nsIPermissionManager::EXPIRE_SESSION) {
       PermissionEntry oldPermissionEntry = entry->GetPermissions()[i];