diff mbox

[pph] AST streaming (3/4) (issue4303049)

Message ID 20110323221742.A78D5ED0E@topo.tor.corp.google.com
State New
Headers show

Commit Message

Diego Novillo March 23, 2011, 10:17 p.m. UTC
LTO cleanups.

See http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01556.html for details.


	* lto-streamer-in.c (input_string_internal): Add clarifying
	comments.
	* lto-streamer-out.c (lto_output_string_with_length): Rename from
	output_string_with_length.
	Output 0 to indicate a non-NULL string.  Update all callers to
	not emit 0.
	(lto_output_string): Rename from output_string.  Make extern.
	Update all users.


--
This patch is available for review at http://codereview.appspot.com/4303049
diff mbox

Patch

diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index b86008b..d2f0075 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -140,7 +140,10 @@  input_string_internal (struct data_in *data_in, struct lto_input_block *ib,
   unsigned int loc;
   const char *result;
 
+  /* Read the location of the string from IB.  */
   loc = lto_input_uleb128 (ib);
+
+  /* Get the string stored at location LOC in DATA_IN->STRINGS.  */
   LTO_INIT_INPUT_BLOCK (str_tab, data_in->strings, loc, data_in->strings_len);
   len = lto_input_uleb128 (&str_tab);
   *rlen = len;
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index a66e1fb..d3d8294 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -170,6 +170,9 @@  lto_output_string_with_length (struct output_block *ob,
   s_slot.len = len;
   s_slot.slot_num = 0;
 
+  /* Indicate that this is not a NULL string.  */
+  lto_output_uleb128_stream (index_stream, 0);
+
   slot = (struct string_slot **) htab_find_slot (ob->string_hash_table,
 						 &s_slot, INSERT);
   if (*slot == NULL)
@@ -206,11 +209,8 @@  lto_output_string (struct output_block *ob,
 	           const char *string)
 {
   if (string)
-    {
-      lto_output_uleb128_stream (index_stream, 0);
-      lto_output_string_with_length (ob, index_stream, string,
-				     strlen (string) + 1);
-    }
+    lto_output_string_with_length (ob, index_stream, string,
+				   strlen (string) + 1);
   else
     lto_output_uleb128_stream (index_stream, 1);
 }
@@ -225,12 +225,9 @@  output_string_cst (struct output_block *ob,
 		   tree string)
 {
   if (string)
-    {
-      lto_output_uleb128_stream (index_stream, 0);
-      lto_output_string_with_length (ob, index_stream,
-				     TREE_STRING_POINTER (string),
-				     TREE_STRING_LENGTH (string));
-    }
+    lto_output_string_with_length (ob, index_stream,
+				   TREE_STRING_POINTER (string),
+				   TREE_STRING_LENGTH (string ));
   else
     lto_output_uleb128_stream (index_stream, 1);
 }
@@ -245,12 +242,9 @@  output_identifier (struct output_block *ob,
 		   tree id)
 {
   if (id)
-    {
-      lto_output_uleb128_stream (index_stream, 0);
-      lto_output_string_with_length (ob, index_stream,
-				     IDENTIFIER_POINTER (id),
-				     IDENTIFIER_LENGTH (id));
-    }
+    lto_output_string_with_length (ob, index_stream,
+				   IDENTIFIER_POINTER (id),
+				   IDENTIFIER_LENGTH (id));
   else
     lto_output_uleb128_stream (index_stream, 1);
 }