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


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
--


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