On 8/24/2010 11:00 PM, Sonu wrote: > Hello, any one can tell me, Is IF or switch statement take space in memory or > not? and which one faster......
The instructions take space regardless. But we are talking mere bytes here. That is rather silly and pointless. As to which is faster, a 'switch' is really only useful for where it would take 5 or 6 'if' statements to do the same thing. A 'switch' is supposedly going to generate what is known as a "jump table" behind the scenes. So it helps to have all values be integers (of some sort) and be sequential integers. http://en.wikipedia.org/wiki/Branch_table Really a judgment call, but I reserve 'switch' statements for when I have enough to justify the effort to remember to 'break' each 'case'. -- Thomas Hruska CubicleSoft President Barebones CMS is a high-performance, open source content management system for web developers operating in a team environment. An open source CubicleSoft initiative. Your choice of a MIT or LGPL license. http://barebonescms.com/
