Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Status of optimiza tions - can have n ative buffers
- X-seq: zsh-workers 40731
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Sebastian Gniazdowski <psprint3@xxxxxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Status of optimiza tions - can have n ative buffers
- Date: Sat, 4 Mar 2017 16:00:50 -0800
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=brasslantern-com.20150623.gappssmtp.com
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=D6p80dY+CQkh1XKjbXWxRsBIjLZ4OqVrsvimP68JiaU=; b=qUJyxXaG3oKMmrCL2CTaxEbUgVjWT3FEdN6UMmaeQNW17uZMa8GXl1tcrZ/NJjEbh6 GSmlLD7/B1pZLVMuX/ngFSwGTpw1BMxunYSaNGqmIyxP+jGjbkvktSqBqOtRTss+qBg6 rlvU5SoA01htRO2dHmOp41MtUkO7tknrupvO1AZGMolSL67jsbmVSzDn27T0cIoQnBjn UPsXuIbzVGS9nx+93XvhdguCIhbMQzDkraKb2D902ZyXmwcQTnN+2AfHmAOsNXfCQXG4 J0dW/xRVK0AMC9waH9zxGscaGQCEc7Lna0djbucVCQg278QPcFgIIkfpT0861OQaNkBj 3eRg==
- In-reply-to: <1488635394.1730469.900258024.2D9CA43E@webmail.messagingengine.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1488635394.1730469.900258024.2D9CA43E@webmail.messagingengine.com>
On Mar 4, 5:49am, Sebastian Gniazdowski wrote:
}
} Callgrind reveals the cause:
}
} 59,930,247,427 arrlen_le [/usr/local/bin/zsh-5.3.1-dev-0_O2]
Yeah, I think we've already determined that we're not getting away from
that without a significant rewrite to stop managing arrays as simple
char ** pointers.
Although the following might help in some cases -- (v->start < 0) can't
be true very often or arrlen() would have shown up nearly as much as
arrlen_le(), but maybe this shaves a few unnecessary recounts?
Anyway changing from arrlen_le() to arrlen_gt() removes a couple of
tail calls, so this might get faster, and will also reveal how many
of those arrlen_le() are coming through here.
diff --git a/Src/params.c b/Src/params.c
index 8942fef..6164ba6 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2101,10 +2101,14 @@ getstrvalue(Value v)
if (v->isarr)
s = sepjoin(ss, NULL, 1);
else {
- if (v->start < 0)
- v->start += arrlen(ss);
- s = (arrlen_le(ss, v->start) || v->start < 0) ?
- (char *) hcalloc(1) : ss[v->start];
+ if (v->start < 0) {
+ if ((v->start += arrlen(ss)) < 0)
+ s = (char *) hcalloc(1);
+ else
+ s = ss[v->start];
+ } else
+ s = arrlen_gt(ss, v->start) ?
+ ss[v->start] : (char *) hcalloc(1);
}
return s;
case PM_INTEGER:
Messages sorted by:
Reverse Date,
Date,
Thread,
Author