mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 18:03:36 +00:00
library/pretty_printer.m:
Replace the indent_stack data structure with one that
- can represent deep indentation in a compact data structure,
as long as that indentation consists only of standard indents, and
- can tell you how many code points the current indent stack consists of
*without* counting the code points in all the individual indent pieces
every time.
This yields a big speedup, because the code used to spend a very large
fraction of its time (between 40 and 50%) just counting the code points
in indentation. This was on stress test data which had very deep
indentation, but the cost would have been substantial even on moderately
indented docs.
Now that the indent_stack can represent more than one level of indentation
in one data structure, print up to 30 levels of standard indentation
with just one call to stream.put. By amortizing the overheads of stream.put
over a must larger part of the output, this also yields a significant
speedup.
Move the indent_stack type and its (significantly expanded) set of
operations to after the code that outputs docs, since it is just an
implementation detail (though as explained above, an important detail).
tests/hard_coded/pretty_printer_stress_test.{m,data,exp}:
A stress test for the pretty_printer whose profiling lead to the
identification of the performance problems fixed above.
tests/hard_coded/Mmakefile:
Enable the new test case, now that it is not too expensive to run
on every bootcheck.
2 lines
5 B
Plaintext
2 lines
5 B
Plaintext
done
|