[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [computer-go] Once and only once
> Is there a consensus on list about whether tree search code should be
> written 'once and only once' abstractly, or should it be duplicated and
> written concretely, once for a black node and once for a white node?
I (C++) templatize some functions with the stone colour in the hope that
the compiler will be able to optimize better; that should be allowing me
to have my cake (easy maintenance) and eat it (max speed). It is no more
trouble to write:
template <Stone who,...> int search(){}
as:
template <...> int search(Stone who){}
(the ... is to indicate I already have other template parameters)
However I had to comment out some code like this as gcc 3.2 had trouble
with it; I've just moved to gcc 3.4 so will be uncommenting and seeing
if it works now.
Anyway even if it works it is only a minor optimization; I wouldn't have
two functions unless I'd profiled and it was the lowest hanging fruit.
Darren
_______________________________________________
computer-go mailing list
computer-go@xxxxxxxxxxxxxxxxx
http://www.computer-go.org/mailman/listinfo/computer-go/