Skip to content

Commit

Permalink
update Robin Hood Hashing to 3.11.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Jul 18, 2024
1 parent a553135 commit ed91685
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
1 change: 1 addition & 0 deletions VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ development head (in the master branch):
send debug output to the main window as well as the debug output tab, to avoid important messages getting lost
add a label next to the Jump button that shows the declaration of the script block containing the selection; clicking it runs the Jump menu
sort recipes by correct numerical order, in both the Recipes menu and the Find Recipe panel, on all platforms
update Robin Hood Hashing to 3.11.5 to get some minor fixes


version 4.2.2 (Eidos version 3.2.2):
Expand Down
43 changes: 29 additions & 14 deletions eidos/robin_hood.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// see https://semver.org/
#define ROBIN_HOOD_VERSION_MAJOR 3 // for incompatible API changes
#define ROBIN_HOOD_VERSION_MINOR 11 // for adding functionality in a backwards-compatible manner
#define ROBIN_HOOD_VERSION_PATCH 3 // for backwards-compatible bug fixes
#define ROBIN_HOOD_VERSION_PATCH 5 // for backwards-compatible bug fixes

#include <algorithm>
#include <cstdlib>
Expand Down Expand Up @@ -206,7 +206,7 @@ static Counts& counts() {

// workaround missing "is_trivially_copyable" in g++ < 5.0
// See https://stackoverflow.com/a/31798726/48181
#if defined(__GNUC__) && __GNUC__ < 5
#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__)
# define ROBIN_HOOD_IS_TRIVIALLY_COPYABLE(...) __has_trivial_copy(__VA_ARGS__)
#else
# define ROBIN_HOOD_IS_TRIVIALLY_COPYABLE(...) std::is_trivially_copyable<__VA_ARGS__>::value
Expand Down Expand Up @@ -1820,6 +1820,12 @@ class Table
InsertionState::key_found != idxAndState.second);
}

template <typename... Args>
iterator emplace_hint(const_iterator position, Args&&... args) {
(void)position;
return emplace(std::forward<Args>(args)...).first;
}

template <typename... Args>
std::pair<iterator, bool> try_emplace(const key_type& key, Args&&... args) {
return try_emplace_impl(key, std::forward<Args>(args)...);
Expand All @@ -1831,16 +1837,15 @@ class Table
}

template <typename... Args>
std::pair<iterator, bool> try_emplace(const_iterator hint, const key_type& key,
Args&&... args) {
iterator try_emplace(const_iterator hint, const key_type& key, Args&&... args) {
(void)hint;
return try_emplace_impl(key, std::forward<Args>(args)...);
return try_emplace_impl(key, std::forward<Args>(args)...).first;
}

template <typename... Args>
std::pair<iterator, bool> try_emplace(const_iterator hint, key_type&& key, Args&&... args) {
iterator try_emplace(const_iterator hint, key_type&& key, Args&&... args) {
(void)hint;
return try_emplace_impl(std::move(key), std::forward<Args>(args)...);
return try_emplace_impl(std::move(key), std::forward<Args>(args)...).first;
}

template <typename Mapped>
Expand All @@ -1854,27 +1859,36 @@ class Table
}

template <typename Mapped>
std::pair<iterator, bool> insert_or_assign(const_iterator hint, const key_type& key,
Mapped&& obj) {
iterator insert_or_assign(const_iterator hint, const key_type& key, Mapped&& obj) {
(void)hint;
return insertOrAssignImpl(key, std::forward<Mapped>(obj));
return insertOrAssignImpl(key, std::forward<Mapped>(obj)).first;
}

template <typename Mapped>
std::pair<iterator, bool> insert_or_assign(const_iterator hint, key_type&& key, Mapped&& obj) {
iterator insert_or_assign(const_iterator hint, key_type&& key, Mapped&& obj) {
(void)hint;
return insertOrAssignImpl(std::move(key), std::forward<Mapped>(obj));
return insertOrAssignImpl(std::move(key), std::forward<Mapped>(obj)).first;
}

std::pair<iterator, bool> insert(const value_type& keyval) {
ROBIN_HOOD_TRACE(this)
return emplace(keyval);
}

iterator insert(const_iterator hint, const value_type& keyval) {
(void)hint;
return emplace(keyval).first;
}

std::pair<iterator, bool> insert(value_type&& keyval) {
return emplace(std::move(keyval));
}

iterator insert(const_iterator hint, value_type&& keyval) {
(void)hint;
return emplace(std::move(keyval)).first;
}

// Returns 1 if key is found, 0 otherwise.
size_t count(const key_type& key) const { // NOLINT(modernize-use-nodiscard)
ROBIN_HOOD_TRACE(this)
Expand Down Expand Up @@ -2308,13 +2322,14 @@ class Table

auto const numElementsWithBuffer = calcNumElementsWithBuffer(max_elements);

// calloc also zeroes everything
// malloc & zero mInfo. Faster than calloc everything.
auto const numBytesTotal = calcNumBytesTotal(numElementsWithBuffer);
ROBIN_HOOD_LOG("std::calloc " << numBytesTotal << " = calcNumBytesTotal("
<< numElementsWithBuffer << ")")
mKeyVals = reinterpret_cast<Node*>(
detail::assertNotNull<std::bad_alloc>(std::calloc(1, numBytesTotal)));
detail::assertNotNull<std::bad_alloc>(std::malloc(numBytesTotal)));
mInfo = reinterpret_cast<uint8_t*>(mKeyVals + numElementsWithBuffer);
std::memset(mInfo, 0, numBytesTotal - numElementsWithBuffer * sizeof(Node));

// set sentinel
mInfo[numElementsWithBuffer] = 1;
Expand Down

0 comments on commit ed91685

Please sign in to comment.