Bug 1382904: Optimize XPCOMUtils.generateQI. r?florian
XPCOMUtils.generateQI is called a lot, and the current implementation is
especially inefficient. It relies on calling the stringification slow path
twice for each interface ID, which begins to add up fast given how often it's
called.
MozReview-Commit-ID: 2O87wBVMA2G
--- a/js/xpconnect/loader/XPCOMUtils.jsm
+++ b/js/xpconnect/loader/XPCOMUtils.jsm
@@ -106,18 +106,19 @@ this.XPCOMUtils = {
* property.
*/
generateQI: function XPCU_generateQI(interfaces) {
/* Note that Ci[Ci.x] == Ci.x for all x */
let a = [];
if (interfaces) {
for (let i = 0; i < interfaces.length; i++) {
let iface = interfaces[i];
- if (Ci[iface]) {
- a.push(Ci[iface].name);
+ let name = iface.name || String(iface);
+ if (name in Ci) {
+ a.push(name);
}
}
}
return makeQI(a);
},
/**
* Generate a ClassInfo implementation for a component. The returned object