bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strchrnul speed


From: Ben Pfaff
Subject: Re: strchrnul speed
Date: Mon, 28 Apr 2008 09:58:53 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Eric Blake <address@hidden> writes:

> Any objections against this patch?  I ask because it intentionally
> violates the C99 constraint of not reading beyond the end of an array.
> However, the excess read can only occur on the final longword of an array,
> and only with an aligned longword read, so on all hardware I know of, the
> read won't fault even though it reads more bytes than strictly necessary;
> people accessing volatile I/O memory with side effects on read should not
> be using strchrnul in the first place.  This code gives a much faster
> search than the original byte-wise approach.

This approach will cause false-positive warnings under memory
debuggers such as Valgrind.  However, anyone who notices such a
warning should be able to spot from the comments in the function
that it is still correct code given the assumption you have
above, so I don't think that is a big deal.
-- 
Ben Pfaff 
http://benpfaff.org





reply via email to

[Prev in Thread] Current Thread [Next in Thread]