zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] ztrsub() execution time / 2
Date: Wed, 17 Oct 2018 14:25:03 +0000	[thread overview]
Message-ID: <20181017142503.ueqgcyljm3aalitf@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <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;
>  }


  reply	other threads:[~2018-10-17 14:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-17  4:29 Sebastian Gniazdowski
2018-10-17 14:25 ` Daniel Shahaf [this message]
2018-10-17 19:02   ` Sebastian Gniazdowski
2018-10-17 19:34     ` Daniel Shahaf

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=20181017142503.ueqgcyljm3aalitf@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=sgniazdowski@gmail.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).