diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-01-29 18:45:33 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-01-29 18:45:33 -0800 |
commit | dc843d8cffca8efb3b6285b9efe93924c2a8c8c0 (patch) | |
tree | c3a29dde29cd31095f7b6cf6e4bfef32f689b39e /lib.c | |
parent | 0b9b94005f540e3d4010338c44468aad1f173293 (diff) | |
download | txr-dc843d8cffca8efb3b6285b9efe93924c2a8c8c0.tar.gz txr-dc843d8cffca8efb3b6285b9efe93924c2a8c8c0.tar.bz2 txr-dc843d8cffca8efb3b6285b9efe93924c2a8c8c0.zip |
Optimize merge a little.
* lib.c (merge): Eliminate extra call to cdr by
keeping the result of cdr_l, and working with the location.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -7637,13 +7637,15 @@ val merge(val list1, val list2, val lessfun, val keyfun) val el2 = funcall1(keyfun, first(list2)); if (funcall2(lessfun, el2, el1)) { - val next = cdr(list2); - deref(cdr_l(list2)) = nil; + loc pnext = cdr_l(list2); + val next = deref(pnext); + deref(pnext) = nil; ptail = list_collect_nconc(ptail, list2); list2 = next; } else { - val next = cdr(list1); - deref(cdr_l(list1)) = nil; + loc pnext = cdr_l(list1); + val next = deref(pnext); + deref(pnext) = nil; ptail = list_collect_nconc(ptail, list1); list1 = next; } |