XML writer: refactor write_referenced_types

The code to determine which referenced types to emit is duplicated
in two places within write_referenced_types. Following the previous
commit, the code is identical in both places.

The structure of the function was:

- determine referenced types to emit
- while not empty
  - sort and emit
  - determine referenced types to emit

It is now:

- while true
  - determine referenced types to emit
  - if empty break
  - sort and emit

There is also a check for already emitted types, just before emission.
This conditional can be flattened into the contained emission
conditional, reducing the overall indentation level of the core logic.

Finally, some comments were corrected and adjusted to reflect the
overall changes to control flow.

	* src/abg-writer.cc (write_referenced_types): Rework initial
	emission of types and while loop for progressively discovered
	types into a single while loop. Also flatten the emission
	logic within the loop to reduce indentation level. Adjust
	comments.

There is no change to tests or overall behaviour.

Change-Id: I98a238e3c21e0cc68279eefc7614eac8ddeb0bbf
Signed-off-by: Giuliano Procida <gprocida@google.com>
1 file changed