[lkml]   [2002]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [TRIVIAL] strlen("literal string") -> (sizeof("literal string")-1)
In message <> you write:
> Here is a patch that does the same as what Keith Owens did in
> his patch recently.
> Message-ID: <>
> From: Keith Owens <>
> Subject: [patch] 2.4.19 Generate better code for nfs_sillyrename
> Date: Wed, 28 Aug 2002 07:08:17 GMT
> Using strlen() generates an unnecessary inline function expansion plus
> dynamic stack adjustment. For constant strings, strlen() == sizeof()-1
> and the object code is better.

Disagree. If you really care make strlen use __builtin_constant_p().
Then authors don't have to sacrifice readability.

#define strlen(x) (__builtin_constant_p(x) ? sizeof(x)-1 : __strlen(x))

Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:28    [W:0.072 / U:5.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site