Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] ztrsub() execution time / 2
- X-seq: zsh-workers 43702
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- Subject: Re: [PATCH] ztrsub() execution time / 2
- Date: Wed, 17 Oct 2018 14:25:03 +0000
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to; s=fm1; bh=Baz mqvCuaqm1hD2ETWvkioRTaj8ZXG8ebZDH/xPiiqs=; b=YPe1pY2CnXv5/dv3LxH 49fdaO2HSezgUHjHK/95xpx4+yrp/qc3bgvg60YeSr5YaU8BYp8bmtVUWWLR2z+k BM+YzU4q6+5qJ0a6pcaqCNRykXsi6qCqqzb37DhOg9niOet4LuD4UBx5MTQ7JYok DLUQ1UvRU2ny+LJO3JOaxFfuu7J8w3BnrwBwpRsNu1YiF9gc+nUCSU1IlUIonSqb BHHyXXZXuDhWaYfMVcBN5yq+lytlsimqEc/NJ2wyX93hSK83Ev2p/7aGgDEpbgwS 5dA9uIpWrrdvaSIbOKCIKRDsXfEo54iAVcsB9mECK1VqPoYPoGeGr75eSporhg4j i8g==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=Bazmqv Cuaqm1hD2ETWvkioRTaj8ZXG8ebZDH/xPiiqs=; b=quUULIOm1SWgWqb+q1xjKQ HS6qA26xHUPaCet9PkxM6DPfmKCQKYnaVNxrQL4N+vXdf0UTEBksXKs/5vZj2dOs XXCcp65ag/lFCWh6+kaGPl6yry3zUkvoHLJ/AccNdQi8n9ferJwyRI0HLddxpjCQ PTR8s1YaW5tcOowf+ycPCMkeZCjmZdit0aZnXcQaP+fSYzvTlbpVfdXhcOKyPxXk BojgIdGu5iRx7nLJtpgeL/9QoufyrKjwFDC8+Dm7xGKTmsNzMyYzv5l488J6nV2N u9VQRpMnT6URYnnq/bEgPfIKRCYI+r2aS5EfN4PPIUg+JbkYz2HtqZk0QSci/ZRA ==
- In-reply-to: <CAKc7PVCMrcNChf2macaVBohMVRq=BcJy6QjHM4w22i9tJX1pXw@mail.gmail.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>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVCMrcNChf2macaVBohMVRq=BcJy6QjHM4w22i9tJX1pXw@mail.gmail.com>
Sebastian Gniazdowski wrote on Wed, Oct 17, 2018 at 06:29:08 +0200:
> diff --git a/Src/utils.c b/Src/utils.c
> index 914e30c..1eb8c71 100644
> --- a/Src/utils.c
> +++ b/Src/utils.c
> @@ -5058,23 +5058,23 @@ ztrlenend(char const *s, char const *eptr)
> #endif /* MULTIBYTE_SUPPORT */
>
> /* Subtract two pointers in a metafied string. */
>
> /**/
> mod_export int
> ztrsub(char const *t, char const *s)
> {
> int l = t - s;
>
> while (s != t) {
> - if (*s++ == Meta) {
> + if (*s++ == Meta || (s != t && *s++ == Meta)) {
Thank you for generating the diff with additional context lines.
As far as I can tell, this patch is the sort of transformation that an
optimizing compiler should do by itself. In fact, I'm having a hard time
seeing how the sequence of "BRANCH IF EQUAL" / "BRANCH IF NOT EQUAL" /
"INCREMENT" assembly instructions would be altered by the patch.
If your profiling was performed on zsh compiled with -O3, I would suggest that
you file a bug against your compiler's optimizer.
> #ifdef DEBUG
> if (! *s || s == t)
> fprintf(stderr, "BUG: substring ends in the middle of a metachar in ztrsub()\n");
> else
> #endif
> s++;
> l--;
Cheers,
Daniel
> }
> }
> return l;
> }
Messages sorted by:
Reverse Date,
Date,
Thread,
Author