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

Re: [PATCH 2/3] drmgr/common_pci: Prefer strlen() to check for valid string length



Hello Jeffrey!

On 12/26/22 14:27, Jeffrey Walton wrote:
Do you need strlen? It looks like you only care that the path is
non-empty. You may be able to save on the call to strlen, and instead,
check the first char of the string. So maybe something like:

-       if (node->ofdt_path == NULL)
+       if (! node->ofdt_path[0])
                 return 0;

Using strlen creates a more readable and safer code. And since the string-optimization
routines of the compiler are extremely good these days [1], there is no need trying to
beat the compiler with manual optimizations.

Adrian

[1] https://www.youtube.com/watch?v=f_tLQl0wLUM

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


Reply to: