On Mar 13, 4:33 pm, Tobie Langel <tobie.lan...@gmail.com> wrote:
> > It's this latter case where having the args array cached provides
> > significant performance benefit, which I would argue is worth doing,
> > even if it slightly lessens the performance of "someFunc()" with no
> > arguments.  That's the tradeoff we're talking about.
> I don't think that tradeoff is necessary, actually.

@Tobie: Are you saying you don't think we should make this tradeoff
(i.e. we should use Kangax's code) or that you believe we can't get
the best of both worlds?

If the latter, I'm not sure how you manage that.  We're either using
Kangax's code for the inner-most function or the "Improved" code. (As
a reminder to readers, both implementations are available at the
bottom of the source on this page: 
).  Here are the relevant snippets:

      function() {
        return arguments.length
          ? fn.apply(context, args.concat(_slice.call(arguments)))
          : fn.apply(context, args);

    function() {
      var ll = arguments.length;
      args.length = l + ll; while (ll--) args[l+ll] = arguments[ll];
      return fn.apply(context, args);

Where argumens.length is zero, the Improved code has *slightly* more
overhead.  But in the case of arguments > 0, the Improved code reuses
the args array instead of making the _slice.call(), which appears to
be more performant in most cases.

Ergo, it's a tradeoff of some sort - pick your implementation - and I
feel the Improved variant provides more desirable performance
characteristics. It provides the best performance for the slowest case
("the weakest link").  So for most projects I think it will provide
better real-world performance.
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to