]> git.kaiwu.me - quickjs.git/commitdiff
Array.prototype.sort: remove the same value optimization which is not really spec...
authorFabrice Bellard <fabrice@bellard.org>
Mon, 2 Nov 2026 10:51:43 +0000 (11:51 +0100)
committerFabrice Bellard <fabrice@bellard.org>
Mon, 2 Nov 2026 10:51:43 +0000 (11:51 +0100)
quickjs.c

index 61e4977fcf8a67cee68803a68701ef7c20527461..ff19e031fe9666d99dc6b5efdf59da3018f28b3b 100644 (file)
--- 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);