about summary refs log tree commit diff
path: root/Src/params.c
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2016-07-30 10:14:35 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2016-08-01 08:01:28 +0000
commit1a368bf31f2b2e6e96290a4803bdcd81e9f17393 (patch)
tree2a9678d0f590d02cb63a701d72887664e065c872 /Src/params.c
parentfaa163cd5fe9c578e3ed35bd5b10e56b7b357ba7 (diff)
downloadzsh-1a368bf31f2b2e6e96290a4803bdcd81e9f17393.tar.gz
zsh-1a368bf31f2b2e6e96290a4803bdcd81e9f17393.tar.xz
zsh-1a368bf31f2b2e6e96290a4803bdcd81e9f17393.zip
38973: Optimize indexing array parameters.
% () { for 1 in $prefix/zsh/bin/zsh Src/zsh; do $1 -f -c 'a=( {1..1000000} ); repeat 3 time ( repeat 300 : $a[1]  )'; done }
( repeat 300; do; : $a[1]; done; )  1.68s user 0.01s system 98% cpu 1.718 total
( repeat 300; do; : $a[1]; done; )  1.69s user 0.01s system 99% cpu 1.710 total
( repeat 300; do; : $a[1]; done; )  1.69s user 0.01s system 99% cpu 1.714 total

( repeat 300; do; : $a[1]; done; )  0.00s user 0.01s system 72% cpu 0.022 total
( repeat 300; do; : $a[1]; done; )  0.00s user 0.01s system 72% cpu 0.022 total
( repeat 300; do; : $a[1]; done; )  0.01s user 0.01s system 69% cpu 0.023 total
Diffstat (limited to 'Src/params.c')
-rw-r--r--Src/params.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Src/params.c b/Src/params.c
index e7a73657b..33f177ecc 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2026,7 +2026,7 @@ getstrvalue(Value v)
 	else {
 	    if (v->start < 0)
 		v->start += arrlen(ss);
-	    s = (v->start >= arrlen(ss) || v->start < 0) ?
+	    s = (arrlen_le(ss, v->start) || v->start < 0) ?
 		(char *) hcalloc(1) : ss[v->start];
 	}
 	return s;