MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / lookup

Function lookup

rust/stringzilla.rs:946–962  ·  view source on GitHub ↗

Performs a lookup transformation (LUT), mapping contents of a buffer into the same or other memory region, taking a byte substitution value from the provided table. # Arguments `target`: A mutable buffer to populate. `source`: An immutable buffer to map from. `table`: Lookup table of 256 substitution values. # Examples To convert uppercase ASCII characters to lowercase: ``` use stringzilla::s

(target: &mut T, source: &S, table: [u8; 256])

Source from the content-addressed store, hash-verified

944/// ```
945///
946pub fn lookup<T, S>(target: &mut T, source: &S, table: [u8; 256])
947where
948 T: AsMut<[u8]> + ?Sized,
949 S: AsRef<[u8]> + ?Sized,
950{
951 let target_slice = target.as_mut();
952 let source_slice = source.as_ref();
953 assert!(target_slice.len() >= source_slice.len());
954 unsafe {
955 sz_lookup(
956 target_slice.as_mut_ptr() as *mut c_void,
957 source_slice.len(),
958 source_slice.as_ptr() as *const c_void,
959 table.as_ptr() as _,
960 );
961 }
962}
963
964/// Performs a lookup transformation (LUT), mapping contents of a buffer into the same or other
965/// memory region, taking a byte substitution value from the provided table.

Callers 1

lookup_size_checksFunction · 0.70

Calls 3

lenMethod · 0.80
as_ptrMethod · 0.80
sz_lookupFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…