diff options
| author | Stefan Boberg <[email protected]> | 2023-10-11 18:18:56 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-11 18:18:56 +0200 |
| commit | a786e64e5a59d4551f4d25279d589c581c8b2a9e (patch) | |
| tree | 09d0a1d639b570d3310e16c5b1d3de170c9c23d1 /src | |
| parent | pluggable asio transport (#460) (diff) | |
| download | zen-a786e64e5a59d4551f4d25279d589c581c8b2a9e.tar.xz zen-a786e64e5a59d4551f4d25279d589c581c8b2a9e.zip | |
added explicit implementation of IoHash equals operator (#464)
* added explicit implementation of IoHash equals and less than operator using memcpy
This improves codegen on MSVC in particular.
Without this the operator is not inlined and consists of 20 individual (not in a loop) byte-by-byte comparisons each with an associated branch.
With this change we get three comparisons (two uint64, one uint32) and three branches. So less pressure on branch predictors and as the code gets inlined the predictor should hopefully also function better.
Diffstat (limited to 'src')
| -rw-r--r-- | src/zencore/include/zencore/iohash.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/zencore/include/zencore/iohash.h b/src/zencore/include/zencore/iohash.h index 649a59c2c..79ed8ea1c 100644 --- a/src/zencore/include/zencore/iohash.h +++ b/src/zencore/include/zencore/iohash.h @@ -60,6 +60,8 @@ struct IoHash static const IoHash Zero; // Initialized to all zeros inline auto operator<=>(const IoHash& rhs) const = default; + inline bool operator==(const IoHash& rhs) const { return memcmp(Hash, rhs.Hash, sizeof Hash) == 0; } + inline bool operator<(const IoHash& rhs) const { return memcmp(Hash, rhs.Hash, sizeof Hash) < 0; } struct Hasher { |