Duy Nguyen pclo...@gmail.com writes:
glibc's C strncmp version does 4-byte comparison at a time when n =4,
then fall back to 1-byte for the rest. I don't know if it's faster
than a plain always 1-byte comparison though. There's also the hand
written assembly version that compares n from
On Wed, Mar 13, 2013 at 3:59 AM, Junio C Hamano gits...@pobox.com wrote:
strncmp is provided length information which could be taken advantage
by the underlying implementation.
After all, strcmp() could also be optimized to fetch word-at-a-time
while being careful about not overstepping the
On Sun, Mar 10, 2013 at 2:34 PM, Junio C Hamano gits...@pobox.com wrote:
Nguyễn Thái Ngọc Duy pclo...@gmail.com writes:
strncmp is provided length information which could be taken advantage
by the underlying implementation.
I may be missing something fundamental, but I somehow find the
On Sun, Mar 10, 2013 at 11:38 AM, Duy Nguyen pclo...@gmail.com wrote:
glibc's C strncmp version does 4-byte comparison at a time when n =4,
then fall back to 1-byte for the rest.
Looking at this
(http://fossies.org/dox/glibc-2.17/strncmp_8c_source.html), it's not
exactly true.
It would rather
On Sun, Mar 10, 2013 at 12:43 PM, Antoine Pelisse apeli...@gmail.com wrote:
On Sun, Mar 10, 2013 at 11:38 AM, Duy Nguyen pclo...@gmail.com wrote:
glibc's C strncmp version does 4-byte comparison at a time when n =4,
then fall back to 1-byte for the rest.
Looking at this
On Sun, Mar 10, 2013 at 6:54 PM, Antoine Pelisse apeli...@gmail.com wrote:
On Sun, Mar 10, 2013 at 12:43 PM, Antoine Pelisse apeli...@gmail.com wrote:
On Sun, Mar 10, 2013 at 11:38 AM, Duy Nguyen pclo...@gmail.com wrote:
glibc's C strncmp version does 4-byte comparison at a time when n =4,
By the way, if we know the length of the string, we could use memcmp.
This one is allowed to compare 4-bytes at a time (he doesn't care
about end of string). This is true because the value of the length
parameter is no longer at most.
We still need to worry about access violation after NUL
On Sun, Mar 10, 2013 at 7:11 PM, Antoine Pelisse apeli...@gmail.com wrote:
By the way, if we know the length of the string, we could use memcmp.
This one is allowed to compare 4-bytes at a time (he doesn't care
about end of string). This is true because the value of the length
parameter is no
strncmp is provided length information which could be taken advantage
by the underlying implementation. Even better, we need to check if the
lengths are equal before calling strncmp, eliminating a bit of strncmp
calls.
before after
user0m0.548s0m0.516s
user0m0.549s
Nguyễn Thái Ngọc Duy pclo...@gmail.com writes:
strncmp is provided length information which could be taken advantage
by the underlying implementation.
I may be missing something fundamental, but I somehow find the above
does not make any sense.
strcmp(a, b) has to pay attention to NUL in
10 matches
Mail list logo