From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] getstrvalue() optimization
Date: Wed, 09 Nov 2016 12:39:16 +0000 [thread overview]
Message-ID: <20161109123916.175e0bc6@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <1478612273.1810945.781106353.1EF6BF52@webmail.messagingengine.com>
While I'm still looking at this... We always need the string length;
there's no early return between the first two cases and where we ensure
we have it.
pws
diff --git a/Src/params.c b/Src/params.c
index 772345b..ef72cba 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2060,7 +2060,7 @@ getstrvalue(Value v)
{
char *s, **ss;
char buf[BDIGBUFSIZE];
- int len = -1;
+ int len;
if (!v)
return hcalloc(1);
@@ -2237,15 +2237,13 @@ getstrvalue(Value v)
if (v->start == 0 && v->end == -1)
return s;
+ len = strlen(s);
if (v->start < 0) {
- len = strlen(s);
v->start += len;
if (v->start < 0)
v->start = 0;
}
if (v->end < 0) {
- if (len < 0)
- len = strlen(s);
v->end += len;
if (v->end >= 0) {
char *eptr = s + v->end;
@@ -2254,8 +2252,6 @@ getstrvalue(Value v)
}
}
- if (len < 0)
- len = strlen(s);
s = (v->start > len) ? dupstring("") :
dupstring_wlen(s + v->start, len - v->start);
next prev parent reply other threads:[~2016-11-09 12:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20161108133901epcas4p257eb8a5bd308d2393769c4a3a2fc3731@epcas4p2.samsung.com>
2016-11-08 13:37 ` Sebastian Gniazdowski
2016-11-09 12:39 ` Peter Stephenson [this message]
2016-11-10 8:14 ` Sebastian Gniazdowski
2016-11-10 10:44 ` Peter Stephenson
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=20161109123916.175e0bc6@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.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).