Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Is there a "Best" Chess Programming Language?

Author: Paul Byrne

Date: 23:01:26 06/08/02

Go up one level in this thread


On June 08, 2002 at 20:55:17, Jon Dart wrote:

>There are other costs. For example, when initializing an array of objects, many
>compilers will sit in a loop calling the constructors for each object. If you
>know, for example, that the initial class data consists of 0 bytes, you could do
>this with "memset" instead - it will be way faster.

This is a problem I've had with Visual C++ -- it does not seem to be very
bright about initializing arrays of objects.  Even when the object has a
constructor that does nothing at all.  For example

class Move
{
    unsigned data;
public:
    Move() { }
    // lots of other stuff
};

class MoveList
{
    int number;
    Move moves[512];
public:
    MoveList() : number(0) { }
    // etc
};

Everytime I make a MoveList it calls some function to handle the move array
which then does a loop which calls yet another function (which does nothing at
all) 512 times.  Ugh.  I even checked the assembly to see what was going on.

After changing the array to an array of unsigned's and making sure class Move
could convert from and to an unsigned, the nps of the program went up almost
100%...

gcc doesn't seem to have this problem, btw.  So the question is:  am I doing
something silly here?  is there some way to tell the compiler what is going on
without ugly hacks?  :)

This is version 6.0, SP5 with just the standard Maximize Speed compiler options.

-paul



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.