Author: Ricardo Gibert
Date: 22:39:11 09/01/02
Go up one level in this thread
On September 02, 2002 at 00:55:34, Pham Hong Nguyen wrote: >On September 01, 2002 at 23:33:26, Robert Hyatt wrote: > >>On September 01, 2002 at 20:46:55, Pham Hong Nguyen wrote: >> >>>The following article and discussion may be useful for you! >>> >>>http://www.codeguru.com/cpp_mfc/switch.html >> >> >>That is basically wrong. >> >>Compile a simple piece of code with gcc, using -O and you will see >>why. >> >>gcc creates a jump table of addresses for each case. It computes the >>entry to load and jumps to that. No compares and branches. Someone > >How can switch not compare when values are not continueing? >For example, >case -1; >case 3; >case 10; >case 234; You perform a "goto" to one of the elements of an array of addresses (the jump table) as indexed by the case value. When the case values are in a fairly narrow range as it is often in a chess program, then this is a practical optimization. > >>doesn't know how compilers do things. If you have really oddball case >>value, it might have to resort to that. But for the kinds of values >>we use in chess, no way...
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.