sharkdp / bat

A cat(1) clone with wings.
Apache License 2.0
48.97k stars 1.23k forks source link

Update bat's tab expansion preprocessor to use bat's ANSI escape sequence iterator. #2998

Closed eth-p closed 3 months ago

eth-p commented 3 months ago

This pull request updates bat's tab expansion preprocessing function to use bat's vscreen::EscapeSequenceOffsetsIterator instead of console::AnsiCodeIterator.

Benchmarks

When running against a file with no tabs, there are no observable differences:

image

And when running against a file[^1] with 34443 tab characters, the difference is negligible:

image

However, it did trim a little over 16 KiB off the file size:

stat bat-master target/release/bat -c "%-20n %s"
# bat-master           5241880
# target/release/bat   5225368

[^1]: Command to create the file: file fd --glob '*.rs' --exec-batch sh -c 'cat "$@" > lots-of.rs' {} && sed -i "s/ /\t/g" lots-of.rs