public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Clean up pretty printers [4/n]
@ 2013-08-05  6:32 Gabriel Dos Reis
  0 siblings, 0 replies; only message in thread
From: Gabriel Dos Reis @ 2013-08-05  6:32 UTC (permalink / raw)
  To: gcc-patches


This patchlet has print_c_tree use non-static local variable for its
pretty-printer object.  The code is much simpler that way.
(A follow up will add destructor so we stop leaking storage.)

Tested on an x86_64-suse-linux.  Applied to trunk.

-- Gaby


2013-08-05  Gabriel Dos Reis  <gdr@integrable-solutions.net>

	* c-pretty-print.c (print_c_tree): Simplify.  Use non-static local
	c_pretty_printer variable.

Index: c-family/c-pretty-print.c
===================================================================
--- c-family/c-pretty-print.c	(revision 201479)
+++ c-family/c-pretty-print.c	(working copy)
@@ -2359,22 +2359,13 @@
 void
 print_c_tree (FILE *file, tree t)
 {
-  static c_pretty_printer pp_rec;
-  static bool initialized = 0;
-  c_pretty_printer *pp = &pp_rec;
-
-  if (!initialized)
-    {
-      initialized = 1;
-      pp_construct (pp, NULL, 0);
-      pp_c_pretty_printer_init (pp);
-      pp_needs_newline (pp) = true;
-    }
-  pp->buffer->stream = file;
-
-  pp_statement (pp, t);
-
-  pp_newline_and_flush (pp);
+  c_pretty_printer pp;
+  pp_construct (&pp, NULL, 0);
+  pp_c_pretty_printer_init (&pp);
+  pp_needs_newline (&pp) = true;
+  pp.buffer->stream = file;
+  pp_statement (&pp, t);
+  pp_newline_and_flush (&pp);
 }
 
 /* Print the tree T in full, on stderr.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-08-05  6:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-05  6:32 Clean up pretty printers [4/n] Gabriel Dos Reis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).