On Wed, 14 Apr 2021 at 07:22, Hugh McMaster hugh.mcmaster@outlook.com wrote:
On Wed, 14 Apr 2021 at 00:17, Gijs Vermeulen wrote:
Not sure if it matters much, but isn't using lstrlenW() going to be more expensive than using ARRAY_SIZE() for the same thing?
While the sizeof() calculations in the ARRAY_SIZE() macro occur at compile-time (meaning no cost), lstrlenW() and friends are highly optimized for speed. Some implementations of strlen() are even written in assembly for even more speed.
That's true for glibc's strlen(), and in cases where gcc can determine the string length at compile time it may replace instances of strlen() with a constant, but it's not quite true for Wine's strlenW(), which has a fairly straightforward/naïve implementation. Still, it seems unlikely to be especially consequential, one way or the other.