Bug 1280485 - Don't sort permission list to improve tab load performance. r=Gijs draft
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 17 Jun 2016 14:59:01 +0100
changeset 380673 c3370c98e4ede164ee48acabfaf51a032fbe22ef
parent 379746 5f95858f8ddf21ea2271a12810332efd09eff138
child 523775 b88a0473998523c60fffb537fda90c6a699fa3cc
push id21277
push usermail@johann-hofmann.com
push dateWed, 22 Jun 2016 16:19:07 +0000
reviewersGijs
bugs1280485
milestone50.0a1
Bug 1280485 - Don't sort permission list to improve tab load performance. r=Gijs MozReview-Commit-ID: CIOY5G1v44u
browser/modules/SitePermissions.jsm
--- a/browser/modules/SitePermissions.jsm
+++ b/browser/modules/SitePermissions.jsm
@@ -28,17 +28,17 @@ this.SitePermissions = {
    *   - label: the translated label of that state
    */
   getPermissionsByURI: function (aURI) {
     if (!this.isSupportedURI(aURI)) {
       return [];
     }
 
     let permissions = [];
-    for (let permission of this.listPermissions()) {
+    for (let permission of kPermissionIDs) {
       let state = this.get(aURI, permission);
       if (state === this.UNKNOWN) {
         continue;
       }
 
       let availableStates = this.getAvailableStates(permission).map( state => {
         return { id: state, label: this.getStateLabel(permission, state) };
       });
@@ -59,17 +59,17 @@ this.SitePermissions = {
    * (meaning allowed or session-allowed) permissions for the given URI.
    * Will return false for invalid URIs (such as file:// URLs).
    */
   hasGrantedPermissions: function (aURI) {
     if (!this.isSupportedURI(aURI)) {
       return false;
     }
 
-    for (let permission of this.listPermissions()) {
+    for (let permission of kPermissionIDs) {
       let state = this.get(aURI, permission);
       if (state === this.ALLOW || state === this.SESSION) {
         return true;
       }
     }
     return false;
   },
 
@@ -79,21 +79,17 @@ this.SitePermissions = {
    */
   isSupportedURI: function (aURI) {
     return aURI.schemeIs("http") || aURI.schemeIs("https");
   },
 
   /* Returns an array of all permission IDs.
    */
   listPermissions: function () {
-    let array = Object.keys(gPermissionObject);
-    array.sort((a, b) => {
-      return this.getPermissionLabel(a).localeCompare(this.getPermissionLabel(b));
-    });
-    return array;
+    return kPermissionIDs;
   },
 
   /* Returns an array of permission states to be exposed to the user for a
    * permission with the given ID.
    */
   getAvailableStates: function (aPermissionID) {
     if (aPermissionID in gPermissionObject &&
         gPermissionObject[aPermissionID].states)
@@ -250,8 +246,11 @@ var gPermissionObject = {
   },
 
   "indexedDB": {},
 
   "pointerLock": {
     exactHostMatch: true
   }
 };
+
+const kPermissionIDs = Object.keys(gPermissionObject);
+