This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: reduce strlen() calls


On Friday, July 26, 2002, at 02:01  PM, Geoff Keating wrote:

Date: Fri, 26 Jul 2002 13:52:53 -0700
Cc: gcc-patches@gcc.gnu.org
From: Devang Patel <dpatel@apple.com>
X-OriginalArrivalTime: 26 Jul 2002 20:53:05.0682 (UTC) FILETIME=[70A59F20:01C234E6]


On Friday, July 26, 2002, at 01:39 PM, Geoff Keating wrote:

I think, that's what `write_string` macro is doing. But if a string
size is
fixed, why run strlen() to measure it?
GCC is supposed to evaluate strlen() of a constant string at compile
time, so it doesn't actually get called anyway.
Oh, OK. I did not know about it.
Where can I find code to do this in gcc sources?
In expand_builtin_strlen in builtins.c.
Thank you.

So, it only effects compiler bootstrap. On the other side, we are the
ones who pay cost of bootstrap time.
I think you'll find that there is no perceptible impact on the time it
takes to bootstrap either way.

Apart from this, is there any reason not to use fixed size number
for fixed strings?  May be I am missing something obvious?
The obvious reason is that:

- The number might be wrong
- The number might start correct, but then someone might change the
  code and forget to update the number.
I agree. I am revoking my patch.

Thanks,
-Devang


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]