diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-04-19 01:03:17 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-04-19 01:03:17 -0700 |
commit | 9e334c1762dc964c6e267dca3780db3a7c8493c7 (patch) | |
tree | e43c5305122ad6e66876da2bd090399775674d75 /lib.c | |
parent | 9cfc6030cf1c38e37345d8e85396ee03bffa67b3 (diff) | |
download | txr-9e334c1762dc964c6e267dca3780db3a7c8493c7.tar.gz txr-9e334c1762dc964c6e267dca3780db3a7c8493c7.tar.bz2 txr-9e334c1762dc964c6e267dca3780db3a7c8493c7.zip |
No-op optimization in substring.
* lib.c (sub_str): Optimization: if the range spans
the entire string, just return it; don't allocate
a copy.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -3742,6 +3742,8 @@ val sub_str(val str_in, val from, val to) if (ge(from, to)) { return null_string; + } else if (from == zero && eql(to, len)) { + return str_in; } else { size_t nchar = c_num(to) - c_num(from) + 1; wchar_t *sub = chk_wmalloc(nchar); |