Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Speeding code

Author: Tom Kerrigan

Date: 11:43:00 05/12/03

Go up one level in this thread


On May 12, 2003 at 10:38:57, Fermin Serrano wrote:

>	Question 2:
>	-----------------
>	Are 'and' operations faster than == operator?.
>	I can use "if (flag == TRUE)" or "if (flag & TRUE)" with the same effect. What
>is faster?

They are the same. Subtraction (the == operator, basically) and ANDing are both
single-cycle operations.

>	Question 3:
>	-----------------
>	To copy a structure into other, what is faster, doing by copy each of his
>elements or use a memcpy?

Use memcpy. It may not be faster on your system, but it's optimized on other
systems that you might use later. If you copy individual elements yourself,
there's no chance it will be optimized on any system.

(Of course, if it's a tiny structure, copying element by element will generally
be faster because you're avoiding the function call overhead.)

-Tom



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.