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: tweak tree-pretty-print.c


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


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