Improve Stats definition

Use operator const T&() instead of operator T() to avoid possible
costly hidden copies of non-scalar nested types.

Currently StatsEntry has a single member T, so assuming
sizeof(StatsEntry) == sizeof(T) it happens to work, but it's
better to use the size of the proper entry type in std::fill.
Note that current code works because std::array items are ensured
to be allocated in contiguous memory and there is no padding among
nested arrays. The latter condition does not seem to be strictly
enforced by the standard, so be careful here.

Finally use address-of operator instead of get() to fully hide the
wrapper class StatsEntry at calling sites. For completness add
the arrow operator too and simplify the C++ code a bit more.

Same binary code as previous master under the Clang compiler.

No functional change.
This commit is contained in:
Marco Costalba
2018-07-28 15:33:39 +02:00
committed by Stéphane Nicolet
parent fae57273b2
commit 571f54b176
3 changed files with 22 additions and 21 deletions

View File

@@ -63,9 +63,9 @@ void Thread::clear() {
for (auto& to : continuationHistory)
for (auto& h : to)
h.get()->fill(0);
h->fill(0);
continuationHistory[NO_PIECE][0].get()->fill(Search::CounterMovePruneThreshold - 1);
continuationHistory[NO_PIECE][0]->fill(Search::CounterMovePruneThreshold - 1);
}
/// Thread::start_searching() wakes up the thread that will start the search