1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-04-14 00:58:43 +02:00
This commit is contained in:
Andrew Gallant 2016-11-06 19:48:17 -05:00
parent a3a2f0be6a
commit 6884eea2f5

View File

@ -550,9 +550,10 @@ impl InputBuffer {
keep_from: usize, keep_from: usize,
) -> Result<bool, io::Error> { ) -> Result<bool, io::Error> {
// Rollover bytes from buf[keep_from..end] and update our various // Rollover bytes from buf[keep_from..end] and update our various
// pointers. N.B. This could be done with the unsafe ptr::copy, but // pointers. N.B. This could be done with the ptr::copy, but I haven't
// I haven't been able to produce a benchmark that notices a difference // been able to produce a benchmark that notices a difference in
// in performance. (Invariably, ptr::copy is also clearer IMO.) // performance. (Invariably, ptr::copy is seems clearer IMO, but it's
// unsafe.)
self.tmp.clear(); self.tmp.clear();
self.tmp.extend_from_slice(&self.buf[keep_from..self.end]); self.tmp.extend_from_slice(&self.buf[keep_from..self.end]);
self.buf[0..self.tmp.len()].copy_from_slice(&self.tmp); self.buf[0..self.tmp.len()].copy_from_slice(&self.tmp);