hey

thanks for all of your responses

al.z


On 25 Jun 2008, at 16:24, Juan Pablo Califano wrote:

I doubt there's a noticeable difference between a switch and a series of if
/else if statements.

In AS 3.0 bytecode, though, switches and equivalent conditionals are not necessarily compiled into the same bytecode. In fact, there's a lookupswitch instruction (opcode 0x1b). Of course, any switch can be implemented as a series of if / else if statements, but that's up to the compiler. From my (limited) experience, the Flash IDE always uses a switch bytecode whenever
it finds a switch construct in Actionscript code. I don't know how it
affects runtime performance, but my guess is that it doesn't have much
impact. And, thinking about it, maybe that opcode exists because it's an
optimized way to compile / execute a series of related conditions.

Cheers
Juan Pablo Califano


2008/6/25, eric e. dolecki <[EMAIL PROTECTED]>:

Switch/case is a bit quicker.

On Wed, Jun 25, 2008 at 10:12 AM, Allandt Bik-Elliott (Receptacle) <
[EMAIL PROTECTED]> wrote:

Hi guys

quick question that came up in a conversation I had the other day - are
switch statements more or less efficient than a series of if...else
statements in either AS2 or AS3?

I'd always thought that the most efficient was the switch

al.z

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to