Skip to content

Commit

Permalink
add hook_LIST_push (#1005)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dwight Guth authored Mar 6, 2024
1 parent bed6e0c commit 9304243
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions runtime/collections/lists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 9304243

Please sign in to comment.