]> git.sesse.net Git - stockfish/commitdiff
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)
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.


No differences found