On 27-Jan-22 04:27, Daniel Stenberg via curl-library wrote:
I'm not familiar with the OpenLDAP exercise, but I also doubt that sizeof would be slow. Even really, really old, dumb compilers turn them into constants.On Thu, 27 Jan 2022, Gavin Henry wrote:I remember in the OpenLDAP project when they removed/reduced the amount of times sizeofs that were used for performance gains.When is sizeof ever a slow operation?As we're only using C89, our sizeof uses are only ever for types/structs, and I can't see how those are not just converted to a constant at compile-time by the compiler.
Perhaps the win was from reducing strlen() calls? They are often overused, and while they can be optimized to some extent, they are inherently slow at runtime. Unless a compiler is smart enough to detect a string constant, where x is a constant replacing strlen(x) with (sizeof(x)-1) can be a win - which may have been what jogged this memory...
Timothe Litt ACM Distinguished Engineer -------------------------- This communication may not represent the ACM or my employer's views, if any, on the matters discussed.
OpenPGP_signature
Description: OpenPGP digital signature
-- Unsubscribe: https://lists.haxx.se/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html