From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: "git\@vger.kernel.org" <git@vger.kernel.org>,
Duy Nguyen <pclouds@gmail.com>,
Ramsay Jones <ramsay@ramsayjones.plus.com>
Subject: Re: [PATCHv2] pathspec: allow escaped query values
Date: Thu, 02 Jun 2016 16:01:33 -0700 [thread overview]
Message-ID: <xmqq60trry9e.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <CAGZ79kYL_47ptjK1S++Z=JUBOQtG1MJS=h0i=9f3fzRmbZDf-g@mail.gmail.com> (Stefan Beller's message of "Thu, 2 Jun 2016 15:53:14 -0700")
Stefan Beller <sbeller@google.com> writes:
> Thinking about efficiency, I have the believe that memmove can be faster
> than a `*src=*dst` thing we do ourselves as it may have access to specialized
> assembly instructions to move larger chunks of memory or such.
> So I think ideally we would do a block copy between the escape characters
> (sketched as:)
>
> last = input
> while input not ended:
> current = find next escape character in input
> memcpy from input value in the range of last to current
> last = current + 1
> copy remaining parts if no further escape is found
That would be true _only_ when "find next escape and copy up to that
byte" aka "scanning once with optimized strchr(), and copying once
with optimized memmove()" is faster than "scanning once and copying"
loop.
I was merely reacting to your use of memmove() in a very different
loop, where if you unescape "a\b\c\defghijk", your memmove() would
move "efghijk" many times.
>> ret = xmalloc(strlen(value));
>
> xmallocz at least?
Yes. Also the handling of the terminating NUL may need to be
updated. That is why I did not say "replace yours with this", but
merely "along the lines of this" ;-)
prev parent reply other threads:[~2016-06-02 23:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 21:30 [PATCHv2] pathspec: allow escaped query values Stefan Beller
2016-06-02 21:54 ` Junio C Hamano
2016-06-02 22:10 ` Stefan Beller
2016-06-02 22:53 ` Stefan Beller
2016-06-02 23:01 ` Junio C Hamano [this message]
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=xmqq60trry9e.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=ramsay@ramsayjones.plus.com \
--cc=sbeller@google.com \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.