diff options
Diffstat (limited to 'src/world.cpp')
| -rw-r--r-- | src/world.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/world.cpp b/src/world.cpp index 89c127cc..1c7c45c9 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -33,9 +33,12 @@ struct world::robin_map_wrapper final : tsl::robin_map<object_id, bptr<object>, world::world(world&& w) noexcept = default; -world::world(std::unordered_map<chunk_coords_, chunk>&& chunks) : - world{std::max(initial_capacity, size_t(1/max_load_factor * 2 * chunks.size()))} +world::world(std::unordered_map<chunk_coords_, chunk, chunk_coords_hasher>&& chunks) { + const auto capʹ = (size_t)(1e-4f + (float)chunks.size() / max_load_factor); + const auto cap = std::max(capʹ, initial_capacity); + _chunks.reserve(cap); + _chunks.max_load_factor(max_load_factor); for (auto&& [coord, c] : chunks) operator[](coord) = move(c); } |
