Segment.adjust_line_length() is called in a hot path during table and syntax rendering, and it currently recomputes line width from the segments each time.
I prototyped a compatibility-preserving change that lets internal callers pass a precomputed line_length, so the hot path can avoid repeating sum(segment.cell_length for segment in line).
ASV results on local TableSuite benchmark:
- heavy wrapping:
22.3 ms -> 21.8 ms\n- no wrapping: 12.1 ms -> 11.7 ms
Segment.adjust_line_length()is called in a hot path during table and syntax rendering, and it currently recomputes line width from the segments each time.I prototyped a compatibility-preserving change that lets internal callers pass a precomputed
line_length, so the hot path can avoid repeatingsum(segment.cell_length for segment in line).ASV results on local
TableSuitebenchmark:22.3 ms -> 21.8 ms\n- no wrapping:12.1 ms -> 11.7 ms