From: Bart Schaefer <schaefer@brasslantern.com>
To: Sebastian Gniazdowski <psprint3@fastmail.com>, zsh-workers@zsh.org
Subject: Re: Status of optimiza tions - can have n ative buffers
Date: Sat, 4 Mar 2017 16:00:50 -0800 [thread overview]
Message-ID: <170304160050.ZM28828@torch.brasslantern.com> (raw)
In-Reply-To: <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:
next prev parent reply other threads:[~2017-03-05 0:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-04 13:49 Status of optimizations – can have native buffers Sebastian Gniazdowski
2017-03-04 15:33 ` Sebastian Gniazdowski
2017-03-05 0:00 ` Bart Schaefer [this message]
2017-03-05 9:32 ` Status of optimiza tions - can have n ative buffers Sebastian Gniazdowski
2017-03-05 16:29 ` Bart Schaefer
2017-03-13 9:01 ` Status of optimizations – can have native buffers Sebastian Gniazdowski
2017-03-13 10:51 ` Sebastian Gniazdowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=170304160050.ZM28828@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=psprint3@fastmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).