Hello, On Wed, Oct 21, 2026 at 12:29:19PM +0900, Youngkwang Lee wrote: > uri_normalizer_percent_decode_unreserved() and > uri_normalizer_percent_upper() walked their input one byte at a time, > appending every single byte to the output even when no percent sign was > involved. For URIs that contain few or no escape sequences, which is the > common case, this copies the whole string byte by byte. > > Only '%' sequences need per-byte handling. Locate the next '%' with > memchr() and copy the run preceding it in one memcpy(), then handle the > escape sequence exactly as before. The output is unchanged, including > the strict mode error behaviour for truncated or invalid sequences.
I actually think it could be even more efficient to immediately check after a %XX if the next char is a '%' before deciding to go with memchr(). Because all UTF-8 encoded text will appear as sequences of multiple %XX, so calling memchr() to look for a '%' that is already at the start pointer seems to be a waste of energy. That way the memchr() call would serve to report the next non-adjacent '%'. Thanks, Willy

