Skip to content

Commit

Permalink
replace unmaintained safemem::copy_over with slice::copy_within
Browse files Browse the repository at this point in the history
* the `safemem` library is [unmaintained][1]
* both `safemem::copy_over` and `slice::copy_within` use `ptr::copy`
  internally, so the performance impact should me minimal.
* `slice::copy_within` was added in rust 1.37.0, but I don't know if
  lol-html has an official MSRV

[1]: https://rustsec.org/advisories/RUSTSEC-2023-0081.html
  • Loading branch information
syphar committed Mar 9, 2024
1 parent 2a0b727 commit ffef8c1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ encoding_rs = "0.8.13"
lazycell = "1.3.0"
lazy_static = "1.3.0"
memchr = "2.1.2"
safemem = "0.3.3"
selectors = "0.22.0"
thiserror = "1.0.2"
hashbrown = "0.13.1"
Expand Down
7 changes: 2 additions & 5 deletions src/memory/arena.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::{MemoryLimitExceededError, SharedMemoryLimiter};
use safemem::copy_over;

/// Preallocated region of memory that can grow and never deallocates during the lifetime of
/// the limiter.
Expand Down Expand Up @@ -48,10 +47,8 @@ impl Arena {
}

pub fn shift(&mut self, byte_count: usize) {
let remainder_len = self.data.len() - byte_count;

copy_over(&mut self.data, byte_count, 0, remainder_len);
self.data.truncate(remainder_len);
self.data.copy_within(byte_count.., 0);
self.data.truncate(self.data.len() - byte_count);
}

pub fn bytes(&self) -> &[u8] {
Expand Down

0 comments on commit ffef8c1

Please sign in to comment.