Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Let the lexer operate on u8 instead of char to improve read performance. #23

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add buffer size config
LinZhihao-723 committed Dec 16, 2024
commit c6da55d210b1a9696ea403ac882a1c4175b5ae3f
6 changes: 3 additions & 3 deletions src/lexer/streams.rs
Original file line number Diff line number Diff line change
@@ -3,13 +3,13 @@ use crate::error_handling::Error::IOError;
use crate::error_handling::Result;
use std::io::{self, BufReader, Read};

const BUF_SIZE: usize = 4096 * 16;
const BUF_SIZE: usize = 4096 * 8;

pub struct BufferedFileStream {
buf_reader: BufReader<std::fs::File>,
pos: usize,
end: usize,
buffer: [u8; 4096],
buffer: [u8; BUF_SIZE],
}

impl BufferedFileStream {
@@ -19,7 +19,7 @@ impl BufferedFileStream {
buf_reader: BufReader::new(file),
pos: 0,
end: 0,
buffer: [0; 4096],
buffer: [0; BUF_SIZE],
}),
Err(e) => Err(IOError(e)),
}