Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/wip5.8.0' into wip5.8.0-32
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Oct 14, 2024
2 parents 8797a69 + d0f846d commit eb59792
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/client/fm_far_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ const MapNode &FarContainer::getNodeRefUnsafe(const v3pos_t &pos)

const auto &storage =
m_client->getEnv().getClientMap().far_blocks_storage[fmesh_step];
if (const auto &it = storage.find(bpos_aligned); it != storage.end()) {
const auto &block = it->second;
if (const auto &block = storage.at_or(bpos_aligned)) {
v3pos_t relpos = pos - bpos_aligned * MAP_BLOCKSIZE;

const auto &relpos_shift = fmesh_step; // + 1;
Expand Down
9 changes: 9 additions & 0 deletions src/threading/concurrent_unordered_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ class concurrent_unordered_map_ : public std::unordered_map<Key, T, Hash, Pred,
return full_type::operator[](std::forward<Args>(args)...);
}

const mapped_type &at_or(const key_type &k, const mapped_type &nothing = {}) const
{
auto lock = LOCKER::lock_shared_rec();
if (const auto it = full_type::find(k); it != full_type::end()) {
return it->second;
}
return nothing;
}

template <typename... Args>
decltype(auto) assign(Args &&...args)
{
Expand Down
2 changes: 1 addition & 1 deletion src/threading/concurrent_unordered_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class concurrent_unordered_set_ : public std::unordered_set<Value, Hash, Pred, A
~concurrent_unordered_set_() { clear(); }

template <typename... Args>
Value &at_or(Args &&...args, const Value &nothing = {})
const Value &at_or(Args &&...args, const Value &nothing = {}) const
{
auto lock = LOCKER::lock_shared_rec();
if (const auto it = full_type::find(std::forward<Args>(args)...);
Expand Down

0 comments on commit eb59792

Please sign in to comment.