Bug 1362224: Speed up permission checks a bit. r?aswan
MozReview-Commit-ID: I6G3gVzSwnJ
--- 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;