summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-04 13:59:58 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-04 13:59:58 +0100
commit295597008e0464f57eb52f51dc5d91ecb4e20cde (patch)
tree265298ead59fcfc7590ed66aa538fdeb068d8f5d /src
parente5659516ff0df4462d1e07308152cd1ebbedf182 (diff)
src/world: remove automatic garbage collection
It should be run in the update loop.
Diffstat (limited to 'src')
-rw-r--r--src/world.cpp11
-rw-r--r--src/world.hpp5
2 files changed, 0 insertions, 16 deletions
diff --git a/src/world.cpp b/src/world.cpp
index b393a403..59ea8d3d 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -45,8 +45,6 @@ world& world::operator=(world&& w) noexcept
_chunks = std::move(w._chunks);
_objects = std::move(w._objects);
w._objects = safe_ptr<robin_map_wrapper>{};
- _last_collection = w._last_collection;
- _collect_every = w._collect_every;
_unique_id = std::move(w._unique_id);
fm_debug_assert(_unique_id);
fm_debug_assert(w._unique_id == nullptr);
@@ -120,24 +118,16 @@ bool world::contains(chunk_coords_ c) const noexcept
void world::clear()
{
fm_assert(!_teardown);
- _last_collection = 0;
_chunks.clear();
_chunks.rehash(initial_capacity);
_objects->clear();
_objects->rehash(initial_capacity);
- _collect_every = initial_collect_every;
_object_counter = object_counter_init;
auto& [c, pos] = _last_chunk;
c = nullptr;
pos = chunk_tuple::invalid_coords;
}
-void world::maybe_collect()
-{
- if (_chunks.size() > _last_collection + _collect_every)
- collect();
-}
-
void world::collect(bool force)
{
const auto len0 = _chunks.size();
@@ -150,7 +140,6 @@ void world::collect(bool force)
++it;
}
- _last_collection = _chunks.size();
auto& [c, pos] = _last_chunk;
c = nullptr;
pos = chunk_tuple::invalid_coords;
diff --git a/src/world.hpp b/src/world.hpp
index 2f5813dd..99ce131f 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -34,8 +34,6 @@ private:
std::unordered_map<chunk_coords_, chunk, chunk_coords_hasher> _chunks;
safe_ptr<robin_map_wrapper> _objects;
- size_t _last_collection = 0;
- size_t _collect_every = initial_collect_every;
std::shared_ptr<char> _unique_id = std::make_shared<char>('A');
object_id _object_counter = object_counter_init;
uint64_t _current_frame = 1; // zero is special for struct object
@@ -62,7 +60,6 @@ public:
bool contains(chunk_coords_ c) const noexcept;
void clear();
void collect(bool force = false);
- void maybe_collect();
size_t size() const noexcept { return _chunks.size(); }
const auto& chunks() const noexcept { return _chunks; }
@@ -70,8 +67,6 @@ public:
void serialize(StringView filename);
static class world deserialize(StringView filename) noexcept(false);
static void deserialize_old(class world& w, ArrayView<const char> buf, uint16_t proto) noexcept(false);
- void set_collect_threshold(size_t value) { _collect_every = value; }
- size_t collect_threshold() const noexcept { return _collect_every; }
auto frame_no() const { return _current_frame; }
auto increment_frame_no() { return _current_frame++; }