From cac8bf56f8dd8876ae3021ae98be693f25515e80 Mon Sep 17 00:00:00 2001
From: Kaz Kylheku <kaz@kylheku.com>
Date: Wed, 12 Jun 2019 20:52:48 -0700
Subject: 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.
---
 lib.c | 2 ++
 txr.1 | 3 +--
 2 files changed, 3 insertions(+), 2 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;
diff --git a/txr.1 b/txr.1
index 15b49b84..dd5eb172 100644
--- a/txr.1
+++ b/txr.1
@@ -26860,8 +26860,7 @@ The description of the
 operator\(emin particular, the section
 on Range Indexing\(emexplains the semantics of the range specification.
 
-If the sequence is a list, the output sequence may share substructure
-with the input sequence.
+The output sequence may share structure with the input sequence.
 
 If
 .meta sequence
-- 
cgit v1.2.3