This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: tweak tree-pretty-print.c
- From: Roger Sayle <roger at eyesopen dot com>
- To: Ben Elliston <bje at au1 dot ibm dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 9 May 2006 07:09:12 -0600 (MDT)
- Subject: Re: PATCH: tweak tree-pretty-print.c
Hi Ben,
On Tue, 9 May 2006, Ben Elliston wrote:
> 2006-05-09 Ben Elliston <bje@au.ibm.com>
>
> * tree-pretty-print.c (pretty_print_string): No need to handle
> '\0' as a special character.
This is OK for mainline, as that code is clearly dead.
Not that its directly related to your change, but from a coding style
perspective, I personally prefer such loops to be written as
for (;;)
{
switch (*str)
{
case '\0':
return;
...
}
str++;
}
instead of
while (*str)
{
switch (*str)
{
...
}
str++;
}
return;
which can often improve the typical case path, if the strings are
expected to be longer than one or two characters. With profiling
optimizations, it should always be an improvement. Indeed, GCC
should eventually be able to perform such "switch aggregation"
optimizations itself.
[My apologies, OpenEye software does a lot of performance critical
string scanning. GCC's pretty_print_string isn't really the same :-)]
Roger
--