http://qs1969.pair.com?node_id=301421


in reply to Re: Re: Perl Idioms Explained: && and || "Short Circuit" operators
in thread Perl Idioms Explained - && and || "Short Circuit" operators

C switch statements create an internal jump table that is more or less like a hash so that they can skip testing cases that are are going to fail, this makes them O(1). For example in the following switch statement if 'test' equals 'c' the code jumps right to case 'c', it doesn't test to see if 'test' equals 'a' or 'b':
switch(test){ case 'a': # do something case 'b': # do something else case 'c': # do something else }
This of course means that the possible cases (but not the test value) are static and must be known at compile time which decreases flexibilty but increases speed.