Re: [PATCHv2] pathspec: allow escaped query values
From: Junio C Hamano <hidden>
Date: 2016-06-16 02:19:43
Stefan Beller [off-list ref] 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 foundThat 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.
quoted
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" ;-)