One thing that nobody who writes switch statements seemed to know (me
included) is you can (and, apparently, should) write them like this:
I knew that. I guess you missed this in my post. After I showed the
switch statement, I said, (or the same thing above but with brackets)
Jason Merrill
- Original Message -
From: Allandt Bik-Elliott (Receptacle) [EMAIL PROTECTED]
To: flashcoders flashcoders@chattyfig.figleaf.com
Sent: Wednesday, June 25, 2008 3:12 PM
Subject: [Flashcoders] switch statement more efficient than if...else?
Hi guys
quick question that came up in a
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
One thing worth noting is switch statement uses strict equality (===)
therefore it's not exactly the same as if/else with equality (==).
Kenneth Kawamoto
http://www.materiaprima.co.uk/
Paul Andrews wrote:
Hi guys
quick question that came up in a conversation I had the other day -
are
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
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
I'd always thought that the most efficient was the switch
I know that the haXe compiler uses a jump table, I'm not sure about
the AS3 compiler. But as already mentioned there is an extra opcode
for switch, and even if the compiler doesn't a jump table, it might
use one in the future.
So, switch
Actually, tt is my (perhaps wrong) understanding that this is not the case.
In the past, both Macromedia and Adobe sources have stated that switch does
not offer a performance boost--just readability and functionality (optional
break lines) enhancements over if statements.
I have been wrong many
and switch on Number ? :P
I read somewhere that Number was quicker than int though I still
can't believe it
cedric
I'd always thought that the most efficient was the switch
I know that the haXe compiler uses a jump table, I'm not sure about
the AS3 compiler. But as already mentioned
I disagree that switch statements are more readable than if else
statements, at least if you put your braces on their own lines.
if (true)
{
// something
}
else if (true)
{
// something else
}
else if (true)
{
// yet another outcome
}
I don't think either is more readable than the
I disagree that switch statements are more readable than if
else statements, at least if you put your braces on their own lines.
I wouldn't disagree, but I think it's more about personal preference.
Maybe it's just aesthetics, but I prefer:
switch(b)
{
case apple:
do
Steven Sacks wrote:
I disagree that switch statements are more readable than if else
statements, at least if you put your braces on their own lines.
I'm a die-hard switch/case guy, but I agree with Steven on this. Neither is
inherently easier or harder to read.
Of course, I personally prefer
better way than nested switches that are 3-4 pages long = if/else statements
;)
On Wed, Jun 25, 2008 at 11:25 PM, Kerry Thompson [EMAIL PROTECTED]
wrote:
Steven Sacks wrote:
I disagree that switch statements are more readable than if else
statements, at least if you put your braces on
One thing that nobody who writes switch statements seemed to know (me
included) is you can (and, apparently, should) write them like this:
switch (n)
{
case 0:
{
foo();
break;
}
case 1:
{
bar();
return;
}
case 2:
{
baz();
14 matches
Mail list logo