More optimal retrival of components: 1) using refs 2) using EcsPool<T>.GetOrDefault(..)

This commit is contained in:
Pavel Shevaev 2024-11-20 12:10:07 +03:00
parent 852f860499
commit c2030384f0
1 changed files with 6 additions and 4 deletions

View File

@ -120,10 +120,11 @@
{%- endif ~%}
{
var pool = world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>();
if(pool.Has(id))
ref var comp = ref pool.GetOrDefault(id, out bool exists);
if(exists)
{
dv = Val.New(frm.vm);
var v = pool.Get(id).{{f.name}};
var v = comp.{{f.name}};
{{ bhl_bind.native2val(f.type, 'v', 'dv') }};
}
else
@ -160,13 +161,14 @@
var pool = world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>();
if(pool.Has(id))
ref var comp = ref pool.GetOrDefault(id, out bool exists);
if(exists)
{
{%~ if m.returntype %}
var return_val =
{%- endif ~%}
pool.Get(id).{{m.name}}(
comp.{{m.name}}(
{%- for arg in m.args ~%} __{{arg.name}}{% if not loop.last %},{% endif %} {%- endfor ~%}
);