BTF Measurements

Kevin Smith khs4473 at gmail.com
Tue Mar 13 09:25:38 PDT 2012


>
> I'm confused by this paragraph. Functions that benefit from 'this'
> binding would reference 'this' or an alias for 'this' right?
>

In this analysis, functions that reference an "alias" to this (e.g. var
self = this) within an inner scope are counted:

    (function() {
        var self = this;
        (function() { console.log(self); });
    });

This results in 1 BTF candidate (the inner function).

In my analysis, I mention that this methodology will tend to undercount the
BTF candidates, because functions with explicitly bound "this" (through
Function.prototype.bind or other means) will tend to get marked as
"methods":

    element.onclick = function() {
        console.log(this);
    }.bind(this);

The analyzer reports 0 BTF candidates, even though we clearly should have
1.  Since the tool undercounts, we can say that the reported numbers offer
a lower bound on BTF candidacy.  The fact that BFT candidacy may be higher
doesn't alter the analysis.

kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120313/c87349d7/attachment.html>


More information about the es-discuss mailing list