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.

perf: fuse TransformSystem double iteration and add nameLen bounds check

esenginecc7c04473322
diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cpp
index b7e184499..02f774ed9 100644
--- a/src/esengine/bindings/WebSDKEntry.cpp
+++ b/src/esengine/bindings/WebSDKEntry.cpp
@@ -119,6 +119,7 @@ bool getMaterialDataWithUniforms(u32 materialId, u32& shaderId, u32& blendMode,
u32 nameLen = *reinterpret_cast<const u32*>(ptr);
ptr += 4;
+ if (nameLen > 256) break;
usize alignedNameLen = ((nameLen + 3) / 4) * 4;
if (ptr + alignedNameLen > bufferEnd) break;
diff --git a/src/esengine/ecs/TransformSystem.hpp b/src/esengine/ecs/TransformSystem.hpp
index 9a29391f5..5e9783ac4 100644
--- a/src/esengine/ecs/TransformSystem.hpp
+++ b/src/esengine/ecs/TransformSystem.hpp
@@ -70,11 +70,9 @@ public:
private:
void updateDirtyTransforms(Registry& registry) {
- registry.each<LocalTransform>([&registry](Entity entity, LocalTransform&) {
+ registry.each<LocalTransform>([&registry, this](Entity entity, LocalTransform& local) {
registry.getOrEmplace<WorldTransform>(entity);
- });
- registry.each<LocalTransform>([&registry, this](Entity entity, LocalTransform& local) {
if (!registry.has<Parent>(entity)) {
bool isStatic = registry.has<TransformStatic>(entity);
bool isDirty = registry.has<TransformDirty>(entity);