Bug 1425600 - Cache nsIPluginTag properties accessed in the plugin blocklist loop. r?Gijs
On my MacBook Pro, this change reduces this loop's time from ~4 ms to ~3 ms. This loop is not hot, but moving these xpconnect calls out of the loop is still a good idea.
MozReview-Commit-ID: ASwb6xZb6ur
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -1106,32 +1106,39 @@ Blocklist.prototype = {
if (!appVersion && !gApp.version)
return Ci.nsIBlocklistService.STATE_NOT_BLOCKED;
if (!appVersion)
appVersion = gApp.version;
if (!toolkitVersion)
toolkitVersion = gApp.platformVersion;
+ const pluginProperties = {
+ description: plugin.description,
+ filename: plugin.filename,
+ name: plugin.name,
+ };
+ const pluginVersion = plugin.version;
+
for (var blockEntry of pluginEntries) {
var matchFailed = false;
for (var name in blockEntry.matches) {
- if (!(name in plugin) ||
- typeof(plugin[name]) != "string" ||
- !blockEntry.matches[name].test(plugin[name])) {
+ let pluginProperty = pluginProperties[name];
+ if (typeof(pluginProperty) !== "string" ||
+ !blockEntry.matches[name].test(pluginProperty)) {
matchFailed = true;
break;
}
}
if (matchFailed)
continue;
for (let blockEntryVersion of blockEntry.versions) {
- if (blockEntryVersion.includesItem(plugin.version, appVersion,
+ if (blockEntryVersion.includesItem(pluginVersion, appVersion,
toolkitVersion)) {
return {entry: blockEntry, version: blockEntryVersion};
}
}
}
return null;
},