From: Fabrice Bellard Date: Mon, 2 Nov 2026 10:51:43 +0000 (+0100) Subject: Array.prototype.sort: remove the same value optimization which is not really spec... X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=1cc74460cb46b986e51231ee560a4493ea14b28a;p=quickjs.git Array.prototype.sort: remove the same value optimization which is not really spec compliant --- 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);