From 1cc74460cb46b986e51231ee560a4493ea14b28a Mon Sep 17 00:00:00 2001 From: Fabrice Bellard Date: Mon, 2 Nov 2026 11:51:43 +0100 Subject: [PATCH] Array.prototype.sort: remove the same value optimization which is not really spec compliant --- quickjs.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/quickjs.c b/quickjs.c index 61e4977..ff19e03 100644 --- a/quickjs.c +++ b/quickjs.c @@ -45038,11 +45038,6 @@ static int js_array_cmp_generic(const void *a, const void *b, void *opaque) { return 0; if (psc->has_method) { - /* custom sort function is specified as returning 0 for identical - * objects: avoid method call overhead. - */ - if (!memcmp(&ap->val, &bp->val, sizeof(ap->val))) - goto cmp_same; argv[0] = ap->val; argv[1] = bp->val; res = JS_Call(ctx, psc->method, JS_UNDEFINED, 2, argv); @@ -45077,7 +45072,6 @@ static int js_array_cmp_generic(const void *a, const void *b, void *opaque) { } if (cmp != 0) return cmp; -cmp_same: /* make sort stable: compare array offsets */ return (ap->pos > bp->pos) - (ap->pos < bp->pos); -- 2.47.3