Skip to content

perf: reduce repeated line-length calculations in segment shaping #4168

@KRRT7

Description

@KRRT7

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions