From 4363f2ed43ff4065ceb03620f5c3ed9e13f7d031 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 1 Jan 2023 13:27:32 -0800 Subject: [PATCH] golf recollide_reanchor Uses fmt in recollide_reanchor. This has a performance impact in code that is already slow so this might need to be reverted; I think that should be part of a comprehensive optimization pass, however, and making it worse for now as part of a general code cleanup is probably better. --- chameleonic.p8 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index 2398aae..3aff870 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -470,8 +470,7 @@ function level:recollide_reanchor() not self:mcoll(mx1,my0) and not self:mcoll(mx1,my1) ) then - local key="GEOM"..mx0..","..my0..","..dx..","..dy - anch_new[key]= { + anch_new[fmt("GEOM%v,%v,%v,%v",mx0,my0,dx,dy)]= { max(mx0,mx1),max(my0,my1),adx=-dx,ady=-dy } end @@ -479,10 +478,9 @@ function level:recollide_reanchor() end for _,cr in pairs(self._crates) do - local key="CRATE"..cr.id..","..dx..","..dy local mx0,my0=cr.mx,cr.my local mx1,my1=mx0+dx,my0+dy - anch_new[key]={ + anch_new[fmt("CRATE%v,%v,%v",cr.id,dx,dy)]={ max(mx0,mx1),max(my0,my1),adx=-dx,ady=-dy } end