reorder scope_dec

This commit is contained in:
dzaima 2022-01-28 04:07:29 +02:00
parent c27c244ccc
commit eca92b6a5d

View File

@ -242,7 +242,7 @@ DEF_FREE(scope) {
} }
FORCE_INLINE void scope_dec(Scope* sc) { // version of ptr_dec for scopes, that tries to also free trivial cycles. force-inlined!! FORCE_INLINE void scope_dec(Scope* sc) { // version of ptr_dec for scopes, that tries to also free trivial cycles. force-inlined!!
i32 varAm = sc->varAm; i32 varAm = sc->varAm;
if (sc->refc>1) { if (LIKELY(sc->refc==1)) goto free;
i32 innerRef = 1; i32 innerRef = 1;
for (i32 i = 0; i < varAm; i++) { for (i32 i = 0; i < varAm; i++) {
B c = sc->vars[i]; B c = sc->vars[i];
@ -254,12 +254,12 @@ FORCE_INLINE void scope_dec(Scope* sc) { // version of ptr_dec for scopes, that
} }
} }
assert(innerRef <= sc->refc); assert(innerRef <= sc->refc);
if (innerRef==sc->refc) { if (innerRef==sc->refc) goto free;
value_free((Value*)sc); sc->refc--; // refc>0 guaranteed by previous refc!=1 result
return; return;
}
} free:
tptr_dec(sc, scope_freeF); scope_freeF((Value*) sc);
} }