Source-Changes-D archive

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

Re: CVS commit: src/usr.bin/make

Am 08.01.2022 um 23:54 schrieb nia:
On Fri, Jan 07, 2022 at 08:04:49PM +0000, Roland Illig wrote:
Using memcmp for comparing the variable name was probably overkill since
the variable names are usually very short, so rather compare them byte
by byte.

I don't see the point of this change - it makes the code harder to
read. We should trust the optimizing compiler, or alternatively trust
that comparing short byte strings isn't particularly expensive.

My idea was that it is usually enough to compare the first byte of the
variable name to see the mismatch, and that the variable names from .for
loops are usually shorter than 8 bytes.  Therefore I wanted to save the
function call to memcmp, as well as the extra comparison for length > 7
that is in x86_64's libc.a(memcmp.o).

I didn't measure whether the speed improvement is noticeable though.
Throwing away 12 lines of code plus a struct looked good to me though,
therefore I went this way.

If I were to extract the newly added code into a function call
cpp_skip_string(&p, varname), would that help?  That function could be
used in var.c as well, for example in ModMatch and ModMatchEq.

Home | Main Index | Thread Index | Old Index