Skip to content

Commit

Permalink
go: add basic skipping
Browse files Browse the repository at this point in the history
Significant performance boost, as expected.
  • Loading branch information
rmg committed Jun 29, 2023
1 parent 46270c3 commit d70c7f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ implementations compare to each other.
| grep | 0m18.034s | 0m15.713s | 0m2.257s |
| ripgrep | 0m1.709s | 0m1.541s | 0m0.147s |
| simple (Go) | 0m1.737s | 0m1.594s | 0m0.142s |
| skip (Go) | 0m0.338s | 0m0.187s | 0m0.152s |
| simple (Rust) | 0m1.461s | 0m1.325s | 0m0.131s |
| skip (Rust) | 0m0.231s | 0m0.105s | 0m0.124s |
| simple (Node) | 0m6.458s | 0m6.043s | 0m0.627s |
Expand Down
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ const BUF = 64 * 4096

func searchWrite(buf []byte, out io.Writer) int {
count := 0
for i, b := range buf {
bl := len(buf)
for i := 0; i < bl; i++ {
b := buf[i]
if count == 0 && i+20 < bl {
bs := buf[i+20]
if !(bs >= '0' && bs <= '9') && !(bs >= 'a' && bs <= 'f') {
i += 20
continue
}
}
switch {
case b >= '0' && b <= '9':
fallthrough
Expand Down

0 comments on commit d70c7f4

Please sign in to comment.