View Single Post
  #26  
Old 02-12-2010, 01:39 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by 12171217 View Post
From what I remember reading, in GS2, the only proper time to use the switch statement is when you want to take advantage of falling through, as it's a less efficient than standard if-than-else.
Hey Downsider,
Although I don't claim to have any knowledge of the specific Bison language parser Stefan created nor any of its specific optimizations, in terms of switch statements in general:
A switch statement can always perform at least as well as a logically equivalent if statement.
A switch statement can perform better than an if statement when the range of values of the switch statement are sufficiently close enough to get compiled to a branch table.

I doubt that optimization has been made in GS2 though, so they are most likely equivalent in terms of performance.
Reply With Quote