aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2025-01-09 06:27:15 +0000
committerGitHub <noreply@github.com>2025-01-09 06:27:15 +0000
commit7321a442a6fc0fc5b6d6ed7af364477d25e706fd (patch)
tree11ff2608e63a160b8b204b6f78ec3977f019d081 /examples
parent89c12df969145ffb5084d1122627d7292c2c638f (diff)
downloadr-alacritty-vte-7321a442a6fc0fc5b6d6ed7af364477d25e706fd.tar.gz
r-alacritty-vte-7321a442a6fc0fc5b6d6ed7af364477d25e706fd.tar.bz2
r-alacritty-vte-7321a442a6fc0fc5b6d6ed7af364477d25e706fd.zip
Switch parser to multi-byte processing
This patch overhauls the `Parser::advance` API to operate on byte slices instead of individual bytes, which allows for additional performance optimizations. VTE does not support C1 escapes and C0 escapes always start with an escape character. This makes it possible to simplify processing if a byte stream is determined to not contain any escapes. The `memchr` crate provides a battle-tested implementation for SIMD-accelerated byte searches, which is why this implementation makes use of it. VTE also only supports UTF8 characters in the ground state, which means that the new non-escape parsing path is able to rely completely on STD's `str::from_utf8` since `memchr` gives us the full length of the plain text character buffer. This allows us to completely remove `utf8parse` and all related code. We also make use of `memchr` in the synchronized escape handling in `ansi.rs`, since it relies heavily on scanning large amounts of text for the extension/termination escape sequences.
Diffstat (limited to 'examples')
-rw-r--r--examples/parselog.rs6
1 files changed, 1 insertions, 5 deletions
diff --git a/examples/parselog.rs b/examples/parselog.rs
index dfd0aee..c41c150 100644
--- a/examples/parselog.rs
+++ b/examples/parselog.rs
@@ -61,11 +61,7 @@ fn main() {
loop {
match handle.read(&mut buf) {
Ok(0) => break,
- Ok(n) => {
- for byte in &buf[..n] {
- statemachine.advance(&mut performer, *byte);
- }
- },
+ Ok(n) => statemachine.advance(&mut performer, &buf[..n]),
Err(err) => {
println!("err: {}", err);
break;