From 3be17ed0d096ec69d6ebfa3051ff2ede66cdd968 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Tue, 19 Nov 2024 11:27:24 +0300 Subject: [PATCH] Starting to use faster EcsPools caching --- tpl/bind_ecslite.twig | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tpl/bind_ecslite.twig b/tpl/bind_ecslite.twig index 0de05e9..cf4c0e6 100644 --- a/tpl/bind_ecslite.twig +++ b/tpl/bind_ecslite.twig @@ -11,7 +11,7 @@ if(e.Unpack(out EcsWorld world, out int id) == false) throw new Exception("No entity found"); - world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id); + world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id); return null; } @@ -34,7 +34,7 @@ if(e.Unpack(out EcsWorld world, out int id) == false) return null; - world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Del(id); + world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>().Del(id); return null; } @@ -59,7 +59,7 @@ if(e.Unpack(out EcsWorld world, out int id) == false) dv.SetBool(false); else - dv.SetBool(world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Has(id)); + dv.SetBool(world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>().Has(id)); stack.Push(dv); return null; @@ -108,22 +108,18 @@ {%- if token_or(f, 'bhl_set', 1) != 0 ~%} if(dv != null) { - ref var cmp = ref world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id); + ref var cmp = ref world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id); {%- if f.type is instanceof('\\mtgArrType') -%} if(dv._obj != null && !dv._obj.Equals(cmp.{{f.name}})) {%- endif ~%} { {{ bhl_bind.val2native(f.type, 'dv', 'cmp.'~f.name) }}; } - //NOTE: uncomment to disable 'dv' variable re-use - //dv.Release(); - //dv = Val.New(frm.vm); - //{{ bhl_bind.native2val(f.type, 'cmp.'~f.name, 'dv') }}; } else {%- endif ~%} { - var pool = world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>(); + var pool = world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>(); if(pool.Has(id)) { dv = Val.New(frm.vm); @@ -162,7 +158,7 @@ if(e.Unpack(out EcsWorld world, out int id) == false) throw new Exception("No entity found"); - var pool = world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>(); + var pool = world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>(); if(pool.Has(id)) {