Good analyzing!!!

Francis, i think you can change EventBroadcaster to use for(var i in array)
to make a new test demo, then, we can test again, if the new result views
that EventBroadcaster runs as slow as EventDispatcher on Mac, then, it will
be clear? .... hmmm...


2007/3/22, Brian Williams <[EMAIL PROTECTED]>:

Someone already mentioned what it is - the for in loop vs the straight for
loop.

for (var i in array) ends up pushing all the keys of the array on the
stack,
and then popping those off.

for (var i =0; i< array.length; i++) doesn't.

The test attaches 500 listeners to each dispatcher, so when you use the
for
(var i in array), you're pushing quite a few items on the stack, and it's
possible that the mac flash player has slower stack access, or that that
particular opcode is significantly slower.

Note - the eventdispatcher code uses the for (var i in array) explicitly
so
that if a listener is removed from the array while dispatching an event
that
it still dispatches to all listeners.  Be careful if you try to just
change
the loop.

Also, why would you have 500 listeners to one broadcaster?  The vast
majority of the UI code that I've dealt with has 0-2 listeners.  The
difference between the two might be a lot smaller in that case.

--Brian


--
iiley
AsWing http://www.aswing.org
Personal http://www.iiley.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to