Wednesday, July 01, 2020

Re: strlcpy version speed tests?

On 7/1/20 8:05 AM, Luke Small wrote:
> I spoke to my favorite university computer science professor who said
> ++n is faster than n++ because the function needs to store the initial
> value, increment, then return the stored value in the former case,
> while the later merely increments, and returns the value. Apparently,
> he is still correct on modern hardware.
For decades the ++ and *p could be out of order, in different
execution units, writes speculatively queued, assigned to aliased registers,
etc, etc, etc.

Geoff Steckel

No comments:

Post a Comment