From 272d503055084b5846b3992bbf6ae6250892b006 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sun, 3 Mar 2024 22:17:21 +0900 Subject: [PATCH] Use scratch space while swapping instead of push/pop --- src/obj_list.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/obj_list.c b/src/obj_list.c index 3b3e36e..d00a49d 100644 --- a/src/obj_list.c +++ b/src/obj_list.c @@ -437,9 +437,10 @@ static int _list_sorter(KrkValue a, KrkValue b) { } static void list_swap(KrkList *list, size_t i, size_t j) { - krk_push(list->values.values[i]); + krk_currentThread.scratchSpace[0] = list->values.values[i]; list->values.values[i] = list->values.values[j]; - list->values.values[j] = krk_pop(); + list->values.values[j] = krk_currentThread.scratchSpace[0]; + krk_currentThread.scratchSpace[0] = NONE_VAL(); } static int partition(KrkList *list, KrkValue key, int reverse, ssize_t lo, ssize_t hi, ssize_t *lt, ssize_t *gt) {