From 9304243ce190f4b95ded8437bfb2fb558e6bcb34 Mon Sep 17 00:00:00 2001 From: Dwight Guth Date: Wed, 6 Mar 2024 12:21:31 -0600 Subject: [PATCH] add hook_LIST_push (#1005) This is a more efficient way to add one element to the front of the list than creating a new list and calling the concatenation operator. --- runtime/collections/lists.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runtime/collections/lists.cpp b/runtime/collections/lists.cpp index 633a3ac02..5f45558ad 100644 --- a/runtime/collections/lists.cpp +++ b/runtime/collections/lists.cpp @@ -24,6 +24,10 @@ list hook_LIST_concat(SortList l1, SortList l2) { return (*l1) + (*l2); } +list hook_LIST_push(SortKItem value, SortList l) { + return l->push_front(value); +} + bool hook_LIST_in(SortKItem value, SortList list) { for (auto iter = list->begin(); iter != list->end(); ++iter) { if (hook_KEQUAL_eq(*iter, value)) {