]> git.sesse.net Git - stockfish/commit - src/movepick.h
Improve Stats definition
authorMarco Costalba <mcostalba@gmail.com>
Sat, 28 Jul 2018 13:33:39 +0000 (15:33 +0200)
committerStéphane Nicolet <cassio@free.fr>
Wed, 1 Aug 2018 10:40:12 +0000 (12:40 +0200)
commit571f54b176b5c30aaac35bc7bbd255c79cdcb926
tree7e999f04ce8fe8f6a52ef7555ff0025c8244368b
parentfae57273b20468f534cce5843152a21214b5da05
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.
src/movepick.h
src/search.cpp
src/thread.cpp