Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about errors when I change my C code to C++

Author: Uri Blass

Date: 06:48:13 02/26/03

Go up one level in this thread


On February 26, 2003 at 08:45:30, Pat King wrote:

>On February 25, 2003 at 12:40:18, Uri Blass wrote:
>
>>On February 25, 2003 at 12:31:14, Pat King wrote:
>[prior to this Uri and Pat wrote a lot of stuff]
>>>>
>>>>data.h is varaibles when defs.h is definition.
>>>>I learned it from tscp.
>>>>
>>>>some varaibles are dependent on definition so I need to include defs.h first
>>>
>>>I would submit that this is a bad feature of tscp.
>>
>>so what do you think?
>>
>>Do you suggest to include all the definitions and the external varaibles in the
>>same file?
>>
>>I do not see why it is a problem except the error that I reported and finding
>>and fixing the error took me only few minutes.
>>
>I haven't looked at tscp or at your code, but you seem to be saying that you're
>declaring a bunch of variables as extern in a header, with the actual
>declaration hidden somewhere in the source.

It is hidden in the file data.c
If I change a varaible I need to change both data.h and data.c


 This can be a maintenance problem
>because you must remember to change both files.

I do not think that it is significant problem because the time that
I spend on changing names of varaibles is very small relative to the time that I
spend about thinking and changing other things.

I try to do changes that do my program simpler and faster but I can say that I
am disapponted from the speed result of the last change.

The change that I did was simply to change my loops by using the break command.

I have a lot of loops of the following 2 types(I have different varaibles)

Type 1:

do
{
...=...//do not change the condition but I do not know if I can use
this fact to do the program faster
if condition
x=a[x];
else
x=-1
}
While (x!=-1)


Type 2:
while (x>=0)
{
...=...//again do not change the condition
  if (condition)
    x-=8;
   else
    x=-1;
}
			}

In part of the cases the condition is more complicated then if (x!=-1) but x=-1
is enough to make the condition false.

I change it to else break.
I hoped to see some small speed improvement but unfortunately
I did not see it

I saw a small speed improvement after part of the changes but it was gone
after I completed the change.

It may be a compiler random error but I wonder if break has a price in speed
and if there are better way to get out of a loop.

Uri



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.