summaryrefslogtreecommitdiffstats
path: root/buf.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-06-15 00:27:50 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-06-15 00:27:50 -0700
commit3f87793404053b98fe0f6a20fafaf7e841f23f71 (patch)
treed7262e22b49b76c1ab7131af1087db96814be6f3 /buf.c
parent2f2126e0e8b67b63c08ad2d86e07f076233bb2bb (diff)
downloadtxr-3f87793404053b98fe0f6a20fafaf7e841f23f71.tar.gz
txr-3f87793404053b98fe0f6a20fafaf7e841f23f71.tar.bz2
txr-3f87793404053b98fe0f6a20fafaf7e841f23f71.zip
Replace lt(x, zero) pattern.
This slight inefficiency occurs in some 37 places in the code. In most places we replace lt(x, zero) with minusp(x). In a few places, !plusp(x) is used and surrounding logic is simplified. In one case, the silly pattern lt(x, zero) ? t : nil is replaced with just minusp(x). * buf.c (sub_buf, replace_buf): Replace lt. * combi.c (perm, rperm, comb, rcomb): Likewise. * eval.c (do_format_field): Likewise. * lib.c (listref, sub_list, replace_list, split_func, split_star_func, match_str, lazy_sub-str, sub_str, replace_str, sub_vec, replace_vec): Likewise. * match.c (weird_merge): Likewise. * regex.c (match_regex, match_regex_right_old, match_regex_right, regex_prefix_match, regex_range_left, regex_range_right): Likewise.
Diffstat (limited to 'buf.c')
-rw-r--r--buf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/buf.c b/buf.c
index 7d41d336..506ac45a 100644
--- a/buf.c
+++ b/buf.c
@@ -250,7 +250,7 @@ val sub_buf(val buf, val from, val to)
from = zero;
else if (from == t)
from = len;
- else if (lt(from, zero)) {
+ else if (minusp(from)) {
from = plus(from, len);
if (to == zero)
to = len;
@@ -258,7 +258,7 @@ val sub_buf(val buf, val from, val to)
if (null_or_missing_p(to) || to == t)
to = len;
- else if (lt(to, zero))
+ else if (minusp(to))
to = plus(to, len);
from = max2(zero, min2(from, len));
@@ -300,7 +300,7 @@ val replace_buf(val buf, val items, val from, val to)
}
return buf;
- } else if (lt(from, zero)) {
+ } else if (minusp(from)) {
from = plus(from, len);
if (to == zero)
to = len;
@@ -308,7 +308,7 @@ val replace_buf(val buf, val items, val from, val to)
if (null_or_missing_p(to) || to == t)
to = len;
- else if (lt(to, zero))
+ else if (minusp(to))
to = plus(to, len);
from = max2(zero, min2(from, len));