Bug 1362224: Speed up permission checks a bit. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Fri, 05 May 2017 12:28:42 -0700
changeset 573490 0a53bfb0eadd41c90680390727c42cf35caa0bfb
parent 573489 e1fcbbdd1bde8875990f38812ea45bc89f859c75
child 573491 88da9878aadb1c432c550f2ab037e360830d41a3
push id57408
push usermaglione.k@gmail.com
push dateFri, 05 May 2017 21:03:51 +0000
reviewersaswan
bugs1362224
milestone55.0a1
Bug 1362224: Speed up permission checks a bit. r?aswan MozReview-Commit-ID: I6G3gVzSwnJ
toolkit/components/extensions/Extension.jsm
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -1080,19 +1080,19 @@ this.Extension = class extends Extension
 
   observe(subject, topic, data) {
     if (topic === "xpcom-shutdown") {
       this.cleanupGeneratedFile();
     }
   }
 
   hasPermission(perm, includeOptional = false) {
-    let match = /^manifest:(.*)/.exec(perm);
-    if (match) {
-      return this.manifest[match[1]] != null;
+    let manifest_ = "manifest:";
+    if (perm.startsWith(manifest_)) {
+      return this.manifest[perm.substr(manifest_.length)] != null;
     }
 
     if (this.permissions.has(perm)) {
       return true;
     }
 
     if (includeOptional && this.manifest.optional_permissions.includes(perm)) {
       return true;