Depends.

Local variables are faster in some casese because it uses optimized 
registers.  Promotion is also something to watch out for regarding ints in 
loops.

If you're really interested, go ask the FLASM guys to update their tool for 
Flash Player 9, and you can inspect the bytecode to see how much is added by 
certain casting operations.  For something more concerete, look here:

http://www.flex.org/ACDS/AS3TuningInsideAVM2JIT.pdf

http://www.flex.org/ACDS/GC.swf

http://www.flex.org/ACDS/Interpreter.swf

http://www.flex.org/ACDS/JITMovie.swf

----- Original Message ----- 
From: "bobpardoe1959" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, July 27, 2006 12:29 PM
Subject: [flexcoders] Cast or create local var - which is best \ performant


We are haveing a debate here at work regarding the the most performant
\ efficient \ best way of dealing with the casting of objects from one
form to another.

a) One person thinks that casting the object to the correct type each
time it is used is better because casting has a compile time penalty,
but at runtime does not incurr a cost.

b) The other person would have us believe that the creation of a
variable of the correct type and casting the object to it and then
using the local variable (thereby eliminating many casts)is better.

I side with a) on the basis that the creation of the variable and the
garbage collection of it costs more than the casting might.

Bearing in mind that either of these methods might be performed in
hundreds of places in the application.

Is there a difference ? Will any one notice. Is one better ?.

Are we being a little to retentive ?

thanks

BOb






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links








--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to