Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

chore(engine): trim verbose comments from Phase 1 fixes

esenginea2151c50eadc
diff --git a/src/esengine/ecs/DynamicComponent.hpp b/src/esengine/ecs/DynamicComponent.hpp
index d068ef571..93aee97a4 100644
--- a/src/esengine/ecs/DynamicComponent.hpp
+++ b/src/esengine/ecs/DynamicComponent.hpp
@@ -129,10 +129,6 @@ public:
dense_[denseIdx] = last;
std::swap(values_[denseIdx], values_.back());
- // Defensive: an in-dense entity implies its index was
- // covered by sparse_ on emplace. Guard against the case
- // where some future refactor shrinks sparse_ without
- // dense_, instead of trusting the invariant silently.
ES_ASSERT(last.index() < sparse_.size(),
"DynamicComponentPool sparse/dense out of sync");
if (last.index() < sparse_.size()) {
diff --git a/src/esengine/ecs/TransformSystem.hpp b/src/esengine/ecs/TransformSystem.hpp
index e4df020e0..d3af0cc20 100644
--- a/src/esengine/ecs/TransformSystem.hpp
+++ b/src/esengine/ecs/TransformSystem.hpp
@@ -190,12 +190,6 @@ inline void setParent(Registry& registry, Entity child, Entity newParent) {
if (!registry.has<Children>(newParent)) {
registry.emplace<Children>(newParent);
}
- // Defensive dedupe: the normal path already removed child from
- // its old parent's list above, but if Parent/Children got out
- // of sync externally (user code touching components directly,
- // partial loads, or a double-insert via ordering bugs), a
- // naked push_back here would compound the corruption into an
- // infinite-traversal hierarchy.
auto& newChildren = registry.get<Children>(newParent).entities;
if (std::find(newChildren.begin(), newChildren.end(), child) == newChildren.end()) {
newChildren.push_back(child);
diff --git a/src/esengine/ecs/View.hpp b/src/esengine/ecs/View.hpp
index 49f0984f0..99101687e 100644
--- a/src/esengine/ecs/View.hpp
+++ b/src/esengine/ecs/View.hpp
@@ -270,21 +270,11 @@ public:
void each(Func&& func) {
if (!smallest_) return;
- // Snapshot the entity list so the callback can safely
- // emplace/remove components mid-iteration — the snapshot is
- // O(n) up front, but any pool realloc inside the callback
- // would otherwise invalidate a live reference and silently
- // corrupt the iteration.
- //
- // After the snapshot, each step re-checks that the entity
- // still has the smallest component (it may have been removed
- // by the callback). The smallest pool's dense index is no
- // longer used for the fast read, since mutations can reorder
- // it — look the component up by entity instead.
+ // Snapshot tolerates emplace/remove on the smallest pool during the callback.
std::vector<Entity> entities = smallest_->entities();
for (Entity entity : entities) {
- if (!smallestStillHas(entity)) continue;
+ if (!smallest_->contains(entity)) continue;
if (!allHaveExceptSmallest(entity)) continue;
if constexpr (std::is_invocable_v<Func, Entity, Components&...>) {
@@ -303,10 +293,6 @@ private:
return std::get<SparseSet<T>*>(pools_)->getUnchecked(entity);
}
- bool smallestStillHas(Entity entity) const {
- return smallest_->contains(entity);
- }
-
bool allHaveExceptSmallest(Entity entity) const {
return allHaveExceptSmallestImpl(entity, std::index_sequence_for<Components...>{});
}
diff --git a/src/esengine/tilemap/TilemapSystem.hpp b/src/esengine/tilemap/TilemapSystem.hpp
index 1e9df371d..5f371c1f7 100644
--- a/src/esengine/tilemap/TilemapSystem.hpp
+++ b/src/esengine/tilemap/TilemapSystem.hpp
@@ -86,12 +86,6 @@ public:
void setTileProperty(Entity entity, u16 tileId,
const std::string& key, const std::string& value);
- /**
- * Return the property value copied by value — do NOT return a
- * pointer into internal storage. Previous iterations used a
- * file-scope static buffer which corrupted on back-to-back calls
- * and was unsafe across threads.
- */
std::string getTileProperty(Entity entity, u16 tileId,
const std::string& key) const;
diff --git a/tests/ecs/test_registry.cpp b/tests/ecs/test_registry.cpp
index 314f4da79..3d2893653 100644
--- a/tests/ecs/test_registry.cpp
+++ b/tests/ecs/test_registry.cpp
@@ -434,21 +434,15 @@ TEST_CASE("uuid_component") {
TEST_CASE("view_each tolerates mid-iteration emplace on the same pool") {
esengine::ecs::Registry registry;
- std::vector<esengine::Entity> seeds;
for (int i = 0; i < 8; ++i) {
esengine::Entity e = registry.create();
registry.emplace<test::Position>(e, float(i), 0.0f);
- seeds.push_back(e);
}
int visited = 0;
auto view = registry.view<test::Position>();
- view.each([&](esengine::Entity e, test::Position&) {
- (void)e;
+ view.each([&](esengine::Entity, test::Position&) {
++visited;
- // Trigger a pool realloc on the smallest pool while iterating.
- // A naked reference to the dense array would dangle here; the
- // snapshot path keeps iteration valid.
if (visited == 1) {
for (int j = 0; j < 32; ++j) {
esengine::Entity extra = registry.create();
@@ -462,11 +456,9 @@ TEST_CASE("view_each tolerates mid-iteration emplace on the same pool") {
TEST_CASE("view_each tolerates mid-iteration remove of the current entity") {
esengine::ecs::Registry registry;
- std::vector<esengine::Entity> entities;
for (int i = 0; i < 5; ++i) {
esengine::Entity e = registry.create();
registry.emplace<test::Position>(e, float(i), 0.0f);
- entities.push_back(e);
}
int visited = 0;
@@ -486,7 +478,7 @@ TEST_CASE("setParent is idempotent on duplicate reparent") {
esengine::Entity child = registry.create();
esengine::ecs::setParent(registry, child, parent);
- esengine::ecs::setParent(registry, child, parent); // second call
+ esengine::ecs::setParent(registry, child, parent);
const auto& children = registry.get<esengine::ecs::Children>(parent).entities;
CHECK_EQ(children.size(), 1u);
diff --git a/tools/eht/generators/editor_api.py b/tools/eht/generators/editor_api.py
index 506abcf52..8ed6a1df8 100644
--- a/tools/eht/generators/editor_api.py
+++ b/tools/eht/generators/editor_api.py
@@ -14,12 +14,7 @@ from ..field_utils import get_sub_components, get_editor_type, is_color_field
def compute_schema_hash(components: List[Component]) -> str:
- """Deterministic hash of the component schema.
-
- Stable across runs on the same input, invalidated by any added /
- removed / renamed / retyped field. Emitted into generated files so
- build-time drift detection can compare against the source schema.
- """
+ """Stable sha256 over (component, field, type, annotations), truncated."""
h = hashlib.sha256()
for comp in sorted(components, key=lambda c: (c.namespace or '', c.name)):
h.update(f'{comp.namespace or ""}::{comp.name}|'.encode('utf-8'))
@@ -622,12 +617,6 @@ class EditorAPIGenerator:
return lines
def _collect_string_fields(self, comp: Component) -> list:
- """Collect (key, cpp_path) for all std::string-backed editable fields.
-
- Includes both plain string fields and asset-annotated string fields
- (e.g. spine skeleton paths) — the latter can't go through setInt
- because their storage isn't integer-convertible.
- """
string_fields = []
for prop in comp.properties:
if self._is_readonly(prop):