1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,299
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default CompositeSprite destruction

    CompositeSprite destruction


    I do a lot of work with composite sprites. I simplified the current destroy() method, which also should be a little faster. I just skipped the getCount() call, which is not needed since first() will return null if there are no more sprites to be destroyed.

    Code:
    // current
    destroy: function(){
        var me = this,
            surface = me.getSurface(),
            item;
            
        if (surface) {
            while (me.getCount() > 0) {
                item = me.first();
                me.remove(item);
                surface.remove(item);
            }
        }
        me.clearListeners();
    }
    
    // modified
    destroy: function(){
        var me = this,
            surface = me.getSurface(),
            item;
            
        if (surface) {
            while (item = me.first()) {
                me.remove(item);
                surface.remove(item);
            }
        }
        me.clearListeners();
    }

  2. #2
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,299
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default


    Can we turn this into a ticket? This small change will improve performance and reduce code size.

  3. #3
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,299
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default Missing param

    Missing param


    ... and the 2nd param in the call to surface.remove is missing (still not fixed as of B2)

    Let's create a ticket, thank you

    Code:
    // modified
    destroy: function(){
        var me = this,
            surface = me.getSurface(),
            item;
            
        if (surface) {
            while (item = me.first()) {
                me.remove(item);
                surface.remove(item, true);
            }
        }
        me.clearListeners();
    }

  4. #4
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,299
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default


    I overrode the CompositeSprite.destroy method. Now that I'm actually destroying the sprites it takes a lot longer to destroy the group. This is bad, but we need to properly destroy the sprites.

    Code:
    Ext.define('wag.override.draw.CompositeSprite', {
        override: 'Ext.draw.CompositeSprite',
    
        destroy: function () {
            var me = this,
                surface = me.getSurface(),
                item;
    
            if (surface) {
                while (item = me.first()) {
                    me.remove(item);
                    surface.remove(item, true);
                }
            }
            me.clearListeners();
        }
    });