Skip to content

Commit

Permalink
Merge pull request #4 from rmg/improve-rust
Browse files Browse the repository at this point in the history
Minor tweaks to naive rust implementation
  • Loading branch information
rmg authored Mar 21, 2023
2 parents fc4391d + 2124332 commit a335306
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ implementations compare to each other.
| grep | 0m18.034s | 0m15.713s | 0m2.257s |
| ripgrep | 0m1.709s | 0m1.541s | 0m0.147s |
| simple (Go) | 0m1.889s | 0m1.679s | 0m0.211s |
| simple (Rust) | 0m2.169s | 0m1.943s | 0m0.219s |
| simple (Rust) | 0m1.461s | 0m1.325s | 0m0.131s |
| simple (Node) | 0m6.458s | 0m6.043s | 0m0.627s |
| custom (C) | **0m0.222s** | **0m0.079s** | **0m0.141s** |

Expand Down
4 changes: 2 additions & 2 deletions main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn scan_slice(inb: &[u8]) -> usize {
let mut count = 0;
let len = inb.len();
for (i, &b) in inb.into_iter().enumerate() {
if b >= b'0' && b <= b'9' || b >= b'a' && b <= b'f' {
if b.is_ascii_digit() || (b'a'..=b'f').contains(&b) {
count += 1;
continue
}
Expand All @@ -43,7 +43,7 @@ fn scan_slice(inb: &[u8]) -> usize {
}

fn sscan(mut input: impl Read) {
let mut backbuf = vec![0u8; 64*1024*1024];
let mut backbuf = vec![0u8; 64*4096];
let bbuf = backbuf.as_mut_slice();
// let mut bbuf = [0u8; 2*1024*1024];
let mut off = 0;
Expand Down

0 comments on commit a335306

Please sign in to comment.