diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-08-22 02:04:01 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-08-22 02:04:01 -0700 |
commit | ceff5513bb6b309d892ff58149ce16f527ce0011 (patch) | |
tree | c88a5d3d87b0b04dfb71b42891543267cf111a9e | |
parent | 7edaa71c065af361b6a8d5e41a213fb82ed67579 (diff) | |
download | txr-ceff5513bb6b309d892ff58149ce16f527ce0011.tar.gz txr-ceff5513bb6b309d892ff58149ce16f527ce0011.tar.bz2 txr-ceff5513bb6b309d892ff58149ce16f527ce0011.zip |
sub-list: better handling of from value of t.
* lib.c (sub_list): If from is t, then just return nil.
Do not reset it to nil in this case. After this we know from
is not nil; we don't have to check for this inside one
loop. That loop was wastefully iterating over the list in the
from == nil case only to calculate nil.
-rw-r--r-- | lib.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -2399,13 +2399,11 @@ val sub_list(val list, val from, val to) { val len = nil; - if (!list) + if (!list || from == t) return nil; if (null_or_missing_p(from)) from = zero; - else if (from == t) - from = nil; else if (minusp(from)) { from = plus(from, len = length(list)); if (to == zero) @@ -2425,7 +2423,7 @@ val sub_list(val list, val from, val to) val i; for (i = zero; list; list = cdr(list), i = plus(i, one)) { - if (from && ge(i, from)) + if (ge(i, from)) break; } return list; |