mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
perf: optim in read_line
This commit is contained in:
parent
9329c95ce7
commit
2292128d30
1 changed files with 3 additions and 2 deletions
|
|
@ -245,10 +245,11 @@ module Input = struct
|
||||||
if Buf.size buf = 0 then raise End_of_file
|
if Buf.size buf = 0 then raise End_of_file
|
||||||
);
|
);
|
||||||
let j = ref slice.off in
|
let j = ref slice.off in
|
||||||
while !j < slice.off + slice.len && Bytes.get slice.bytes !j <> '\n' do
|
let limit = slice.off + slice.len in
|
||||||
|
while !j < limit && Bytes.get slice.bytes !j <> '\n' do
|
||||||
incr j
|
incr j
|
||||||
done;
|
done;
|
||||||
if !j - slice.off < slice.len then (
|
if !j < limit then (
|
||||||
assert (Bytes.get slice.bytes !j = '\n');
|
assert (Bytes.get slice.bytes !j = '\n');
|
||||||
(* line without '\n' *)
|
(* line without '\n' *)
|
||||||
Buf.add_bytes buf slice.bytes slice.off (!j - slice.off);
|
Buf.add_bytes buf slice.bytes slice.off (!j - slice.off);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue