Skip to content

Commit 988ebcd

Browse files
authored
Merge pull request #688 from kivikakk/push-ylwwmpzkwpkn
jetscii for line searcher.
2 parents 1a38822 + ae45268 commit 988ebcd

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

src/parser/mod.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,22 @@ where
136136
self.total_size = end;
137137

138138
let mut ix = 0;
139+
let matcher = jetscii::bytes!(b'\r', b'\n');
139140

140-
// TODO: jetscii.
141141
while ix < end {
142-
let mut eol = ix;
143-
144-
while eol < end {
145-
match sb[eol] {
146-
b'\r' => {
147-
eol += 1;
148-
if eol < end && sb[eol] == b'\n' {
149-
eol += 1;
150-
}
151-
break;
152-
}
153-
b'\n' => {
142+
let mut eol = match matcher.find(&sb[ix..]) {
143+
Some(offset) => ix + offset,
144+
None => end,
145+
};
146+
if eol < end {
147+
if sb[eol] == b'\r' {
148+
eol += 1;
149+
if eol < end && sb[eol] == b'\n' {
154150
eol += 1;
155-
break;
156151
}
157-
_ => {}
152+
} else if sb[eol] == b'\n' {
153+
eol += 1;
158154
}
159-
eol += 1;
160155
}
161156

162157
self.process_line(&s[ix..eol]);

0 commit comments

Comments
 (0)