ink
ink copied to clipboard
perf: use caches to speed up output generation
Really only noticeable for huge terminals so hard to use the current benchmarks, but anecdotally on my 150x200 terminal it's sped renders up from ~40ms to ~9ms, so almost 5x faster. Presumably it'd be more of a speedup the larger the terminal gets.
All tests (that were passing on current master) are passing.
Output is recreated on every render, so it's unclear to me why this actually improves performance, unless the output has duplicated lines.
I think because there's a lot of redundant processing even within a single output frame. For example:
widestLineis internally callingstringWidthon every line, just to do that again manually later on- more importantly,
stringWidthis getting re-run on every individual character