Bug 1382904: Optimize XPCOMUtils.generateQI. r=florian
authorKris Maglione <maglione.k@gmail.com>
Thu, 20 Jul 2017 18:38:14 -0700
changeset 419064 2513f47a01eae7797edcea19ca09036cecce02c1
parent 419063 d72854694b360ce5051f37256518c3b3a8e69237
child 419065 1165fd9f0b437fd8fc6acc738029911ef23709c8
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1382904
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
js/xpconnect/loader/XPCOMUtils.jsm
--- 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 && iface.name) || String(iface);
+        if (name in Ci) {
+          a.push(name);
         }
       }
     }
     return makeQI(a);
   },
 
   /**
    * Generate a ClassInfo implementation for a component. The returned object