From 6bc4ec6b04043d055bd9cb3127ec717a83e5b4c2 Mon Sep 17 00:00:00 2001 From: cpunch Date: Tue, 23 Feb 2021 11:49:57 -0600 Subject: [PATCH] Improved cosmoO_equals performance for strings --- src/cobj.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cobj.c b/src/cobj.c index 1b4fcfc..5dc445d 100644 --- a/src/cobj.c +++ b/src/cobj.c @@ -107,6 +107,13 @@ bool cosmoO_equal(CState *state, CObj *obj1, CObj *obj2) { goto _eqFail; switch (obj1->type) { + case COBJ_STRING: { + /* + we already compared the pointers at the top of the function, this prevents the `__equal` metamethod + from being checked. If you plan on using `__equal` with strings just remove this case! + */ + return false; + } case COBJ_CFUNCTION: { CObjCFunction *cfunc1 = (CObjCFunction*)obj1; CObjCFunction *cfunc2 = (CObjCFunction*)obj2;