On Thu, 2007-11-15 at 15:20 -0500, Eric Boesch wrote:
> John and Jason's optimization suggestions are both good, but they
> point in different directions. (Of course, John had a complete
> solution to begin with.) I have a 64-bit machine, and in that case I
> think that the bitmask approach, with Jason's addition, is the clear
> choice, creating some pretty tight code:
>
> /** @return true iff the input value is either zero or the sum of
> at most mMaxRepetitions of a single code() value. */
> bool operator()(uint64_t codeSum) const {
> return codeSum < mThreshold && !((codeSum/(codeSum/mDivisor)) &
> mMask);
> }
Looking at this code again, I believe you should replace
(codeSum/mDivisor) with (codeSum>>XXX)
Where XXX is the number of zeros to the right of the one in mDivisor.
This'll reduce it to only one division. It's also possible to use a
switch statement to remove the final division in 3 out of 4 cases.
_______________________________________________
computer-go mailing list
[email protected]
http://www.computer-go.org/mailman/listinfo/computer-go/