===================================================================
@@ -353,24 +353,18 @@
static cxx_binding *
pph_in_cxx_binding (pph_stream *stream)
{
- unsigned i, num_bindings;
- cxx_binding *curr, *cb;
+ cxx_binding *curr, *prev, *cb;
+ /* Read the current binding first. */
+ cb = pph_in_cxx_binding_1 (stream);
+
/* Read the list of previous bindings. */
- num_bindings = pph_in_uint (stream);
- for (curr = NULL, i = 0; i < num_bindings; i++)
+ for (curr = cb; curr; curr = prev)
{
- cxx_binding *prev = pph_in_cxx_binding_1 (stream);
- if (curr)
- curr->previous = prev;
- curr = prev;
+ prev = pph_in_cxx_binding_1 (stream);
+ curr->previous = prev;
}
- /* Read the current binding at the end. */
- cb = pph_in_cxx_binding_1 (stream);
- if (cb)
- cb->previous = curr;
-
return cb;
}
===================================================================
@@ -339,21 +339,18 @@
static void
pph_out_cxx_binding (pph_stream *stream, cxx_binding *cb, bool ref_p)
{
- unsigned num_bindings;
cxx_binding *prev;
- num_bindings = 0;
- for (prev = cb ? cb->previous : NULL; prev; prev = prev->previous)
- num_bindings++;
+ /* Write the current binding first. */
+ pph_out_cxx_binding_1 (stream, cb, ref_p);
/* Write the list of previous bindings. */
- pph_out_uint (stream, num_bindings);
- if (num_bindings > 0)
- for (prev = cb->previous; prev; prev = prev->previous)
- pph_out_cxx_binding_1 (stream, prev, ref_p);
+ for (prev = cb ? cb->previous : NULL; prev; prev = prev->previous)
+ pph_out_cxx_binding_1 (stream, prev, ref_p);
- /* Write the current binding at the end. */
- pph_out_cxx_binding_1 (stream, cb, ref_p);
+ /* Mark the end of the list (if there was a list). */
+ if (cb)
+ pph_out_cxx_binding_1 (stream, NULL, ref_p);
}