Text reflow performance #1 #519

Manually merged
dnkl merged 12 commits from reflow-performance into master 7 months ago
dnkl commented 7 months ago
Owner

This is the first PR, in what I hope will be a series of PRs improving the performance of text reflow. Changes in this PR:

  • Replaced CELL_MULT_COL_SPACER with CELL_SPACER. Besides the name change, the following has changed:
    • For cells following a multi-column character, print CELL_SPACER+n, where n is the number of remaining spacer cells, including the current spacer cell itself (i.e. a double-width character will be followed by a single spacer cell with the value CELL_SPACER+1)
    • The value CELL_SPACER+0 is used when padding at the right margin, to "push" a multi-column character to the next row
  • Stop calling wcwidth() on every cell in the grid - peek the next cell and check for a CELL_SPACER+n value, and use that instead.
  • Stop checking for combining characters. This was previously necessary since we needed to call wcwidth() on the base character. Not anymore.
  • Simplified logic when reflowing queued up empty cells
  • Stop iterating all tracking points (special coordinates that we need to track the translation of - e.g. the current cursor position) on each and every cell. Use a sorted array that step when the "current" tracking point has been translated.

Part of #504.

This is the first PR, in what I hope will be a series of PRs improving the performance of text reflow. Changes in this PR: * Replaced `CELL_MULT_COL_SPACER` with `CELL_SPACER`. Besides the name change, the following has changed: - For cells **following** a multi-column character, print `CELL_SPACER+n`, where `n` is the number of remaining spacer cells, including the current spacer cell itself (i.e. a double-width character will be followed by a single spacer cell with the value `CELL_SPACER+1`) - The value `CELL_SPACER+0` is used when padding at the right margin, to "push" a multi-column character to the next row * Stop calling `wcwidth()` on **every** cell in the grid - peek the next cell and check for a `CELL_SPACER+n` value, and use that instead. * Stop checking for combining characters. This was previously necessary since we needed to call `wcwidth()` on the base character. Not anymore. * Simplified logic when reflowing queued up empty cells * Stop iterating **all** tracking points (special coordinates that we need to track the translation of - e.g. the current cursor position) on **each and every** cell. Use a sorted array that step when the "current" tracking point has been translated. Part of #504.
dnkl added the
performance
label 7 months ago
dnkl added 8 commits 7 months ago
d9e1aefb91
term: rename CELL_MULT_COL_SPACER -> CELL_SPACER, and change its definition
8e05f42a1c
grid: don’t depend on wcwidth()
a5ec26ccc9
grid: reflow: no need to check for combining characters
0d6abf1515
grid: reflow: use a sorted array for tracking points
Poster
Owner

Note: reflow is only done on the "regular" screen, not the alt screen. But do note that both grids are always resized on a window resize (i.e. the regular screen is reflowed, even if you are currenly on the alt screen).

This PR currently logs INFO logs with reflow timing information. To compare with master, checkout the first commmit in this PR.

Note: reflow is only done on the "regular" screen, not the alt screen. But do note that both grids are always resized on a window resize (i.e. the regular screen **is** reflowed, even if you are currenly on the alt screen). This PR currently logs `INFO` logs with reflow timing information. To compare with master, checkout the **first** commmit in this PR.
dnkl added 1 commit 7 months ago
528e91aece
grid: take scrollback start into account when sorting the tracking points array
dnkl added 1 commit 7 months ago
dnkl added 1 commit 7 months ago
dnkl added 1 commit 7 months ago
8d1b724056
grid: reflow: qsort_r() is not portable
dnkl merged commit 3405a9c81c into master manually 7 months ago
The pull request has been manually merged as 3405a9c81c.
Sign in to join this conversation.
Loading…
There is no content yet.