Improved cosmoO_equals performance for strings

This commit is contained in:
cpunch 2021-02-23 11:49:57 -06:00
parent f92ffcecbd
commit 6bc4ec6b04

View File

@ -107,6 +107,13 @@ bool cosmoO_equal(CState *state, CObj *obj1, CObj *obj2) {
goto _eqFail; goto _eqFail;
switch (obj1->type) { 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: { case COBJ_CFUNCTION: {
CObjCFunction *cfunc1 = (CObjCFunction*)obj1; CObjCFunction *cfunc1 = (CObjCFunction*)obj1;
CObjCFunction *cfunc2 = (CObjCFunction*)obj2; CObjCFunction *cfunc2 = (CObjCFunction*)obj2;