1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,483
    Vote Rating
    219
    Answers
    14
    LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of

      0  

    Default Answered: Optimization killers

    Answered: Optimization killers


    See this document in particular these two sections:

    3. Managing arguments, and
    5. For-in

    I see many places in the Ext JS code base where the arguments object is passed where it doesn't need to be passed.

    This article states "The arguments object must not be passed or leaked anywhere."...

    Do you think this code could be optimized?
    Code:
    Ext.define('Ext.button.Button', {
        ...
        initComponent: function() {
            ...
            me.callParent(arguments);
            me.callParent(); // <-- Use this instead?
            ...

  2. In the case of the Button initComponent method you are correct - it is wasteful to pass arguments, when the initComponent method has no arguments. We try to watch out for this internally but ocassionally one slips through the cracks, Thanks for pointing it out, we'll get it fixed.

    In v5 we are incrementally moving more toward this pattern:

    Code:
    foo: function(a, b) {
        this.callParent([a, b]);
    }
    Using an array will allow Sencha Cmd to optimize the callParent call and turn it into something that looks more like this:

    Code:
        this.superclass.foo.call(this, a, b);
    When this kind of optimization is possible it is a huge win for performance, since call takes the cake for speed http://jsperf.com/passing-arguments

  3. #2
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,483
    Vote Rating
    219
    Answers
    14
    LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of

      0  

    Default


    Do you think the "argument leaking" anti-pattern will stop optimization and should Ext JS code be updated?

  4. #3
    Sencha - Ext JS Dev Team Phil Guerrant's Avatar
    Join Date
    May 2011
    Location
    Colorado
    Posts
    336
    Vote Rating
    93
    Answers
    29
    Phil Guerrant is a glorious beacon of light Phil Guerrant is a glorious beacon of light Phil Guerrant is a glorious beacon of light Phil Guerrant is a glorious beacon of light Phil Guerrant is a glorious beacon of light

      2  

    Default


    In the case of the Button initComponent method you are correct - it is wasteful to pass arguments, when the initComponent method has no arguments. We try to watch out for this internally but ocassionally one slips through the cracks, Thanks for pointing it out, we'll get it fixed.

    In v5 we are incrementally moving more toward this pattern:

    Code:
    foo: function(a, b) {
        this.callParent([a, b]);
    }
    Using an array will allow Sencha Cmd to optimize the callParent call and turn it into something that looks more like this:

    Code:
        this.superclass.foo.call(this, a, b);
    When this kind of optimization is possible it is a huge win for performance, since call takes the cake for speed http://jsperf.com/passing-arguments
    Phil Guerrant
    Ext JS - Development Team

Thread Participants: 1