Skip to content

Commit

Permalink
Merge pull request #527 from Dr-Emann/const_generic_fast_string
Browse files Browse the repository at this point in the history
Use const generics to provide FastStrings
  • Loading branch information
wtfsck authored Feb 25, 2024
2 parents d3c1d0f + 26c4b03 commit 7316af0
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 141 deletions.
12 changes: 7 additions & 5 deletions src/rust/iced-x86/src/data_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ impl<'a> DataReader<'a> {
s
}

// Returns the whole slice starting at the current index,
// including the length byte, and advances the index by the current length + 1
#[cfg(feature = "fast_fmt")]
#[allow(trivial_casts)]
pub(crate) fn read_len_data(&mut self) -> *const u8 {
let len = &self.data[self.index];
let len_data = len as *const u8;
self.index += 1 + *len as usize;
pub(crate) fn read_len_data(&mut self) -> &'a [u8] {
let len = usize::from(self.data[self.index]);
debug_assert!(self.index + 1 + len <= self.data.len());
let len_data = &self.data[self.index..];
self.index += 1 + len;
len_data
}
}
Loading

0 comments on commit 7316af0

Please sign in to comment.