summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-06-12 20:52:48 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-06-12 20:52:48 -0700
commitcac8bf56f8dd8876ae3021ae98be693f25515e80 (patch)
treec1ffec4c39b91d86d4b61e4253823bb6faf0a732 /lib.c
parent8ea3c6bfbb82c122bd93abb02a3600c3512ff24c (diff)
downloadtxr-cac8bf56f8dd8876ae3021ae98be693f25515e80.tar.gz
txr-cac8bf56f8dd8876ae3021ae98be693f25515e80.tar.bz2
txr-cac8bf56f8dd8876ae3021ae98be693f25515e80.zip
sub-vec: optimize no-op case.
* lib.c (sub_vec): If range covers entire vector, just return it. * txr.1: Clarify that the output of sub may share structure with the input regardless of type, not only when the input is a list. This should have been updated when the optimizatin was done in sub-str.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 45e5b865..c462a238 100644
--- a/lib.c
+++ b/lib.c
@@ -7144,6 +7144,8 @@ val sub_vec(val vec_in, val from, val to)
if (ge(from, to)) {
return vector(zero, nil);
+ } else if (from == zero && eql(to, len)) {
+ return vec_in;
} else {
cnum cfrom = c_num(from);
size_t nelem = c_num(to) - cfrom;