as3-signals
as3-signals copied to clipboard
Vector.<ISignal> over Array?
Hey, I was wondering if there was a reason why internally Signals uses Arrays over the more efficient Vector.<> type. Is this for backward compatibility reasons? Would it make sense to make the switch? Or are there forks out there that have made this change? :)
Are you talking about the value classes/objects, if so this is because it's utilising the varargs to override the method arguments. You can't use vectors for this and it would be more expensive to wrap the array to vector if you did want to...
https://github.com/robertpenner/as3-signals/blob/master/src/org/osflash/signals/OnceSignal.as#L24
Oh, I see that it has changed quite a bit in master. I was looking at the last tag (0.8) because it's the one I'm using: https://github.com/robertpenner/as3-signals/blob/v0.8/src/org/osflash/signals/Signal.as#L26
I was running my app through Adobe Scout, a it seemed that there was some garbage generation through the slicing of Arrays. That's what led me to this question in the first place.
Have the changes in master proven to be more efficient than 0.8? I'm guessing that removing Slots from a custom Linked List can be a lot more sane than splicing the Vector when removing the listener?
Ah, that would make sense. From a performance point of view it turned out to be a lot faster, but considering this was some flash player releases ago, so I would revisit it again tbh. In terms of memory against 0.8 release I'm not sure, but it was more than adequate for my needs (mobile) as the memory was always low.
I personally would recommend the master version as I was using in production for over 2 years and was always solid.