Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: what classes all the serious C++ chess programs have?

Author: Andrew Dados

Date: 06:52:55 08/10/04

Go up one level in this thread


On August 10, 2004 at 08:28:53, Tord Romstad wrote:

>On August 10, 2004 at 05:37:10, Gerd Isenberg wrote:
>
>>Generic inline wrapper classes for pieces, moves, hashentries etc. are IMHO nice
>>to hide implementation and to write "ugly" code once, without any performance
>>penalty, some examples which same assembly output:
>>
>>   if (piece & 0x80) ...
>>   if (piece & SLIDING_BIT) ...
>>   if (isSlding(piece) ) ...
>>   if (piece.isSliding()) ...
>>or
>>   if (hashentry.flags & 0x01) ...
>>   if (hashentry.flags & LOWER_BOUND) ...
>>   if (hashentry.isLowerBound() ) ...
>>
>>I prefere the latter.
>
>I understand why you want to avoid the '&' variants, but why is
>piece.isSliding() better than isSliding(piece), and hashentry.isLowerBound()
>better than isLowerBound(hashentry)?
>
>Tord


Actually I prefere: if (hashentry.flags & LOWER_BOUND) ...

Reasons:
1) less total writing and less possible places to go wrong
2) faster compile,
3) I can rest assured that it is executed as fast as possible and create
smallest machine code (I am never sure about different compilers treating
template classes or inlining things or switches or...)
4) it is easy to read for other people without referring to some other file

For one-time things I will just use plain code...
-Andrew-



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.