Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: OT: switch Statement Performance Consideration

Author: Pham Hong Nguyen

Date: 21:55:34 09/01/02

Go up one level in this thread


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;

>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.