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: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: Ben Elliston <bje at au1 dot ibm dot com>, gcc-patches at gcc dot gnu dot org
- Date: 09 May 2006 16:23:56 +0200
- Subject: Re: PATCH: tweak tree-pretty-print.c
- References: <Pine.LNX.4.44.0605090649260.3672-100000@www.eyesopen.com>
Roger Sayle <roger@eyesopen.com> writes:
| 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;
and not
for (; *str != '\0'; ++str)
switch (*str)
{
....
}
?
| 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.
yup; that sounds to me as what we should strive for...
-- gaby