Function sarc::sfat_hash

source ·
pub fn sfat_hash(string: &str) -> u32
Expand description

Hashing function used for hashing sfat strings

Examples found in repository?
src/writer.rs (line 156)
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
    fn generate_string_section(&self) -> (HashMap<u32, u32>, Vec<u8>) {
        let mut names: Vec<&str> =
            self.files.iter().filter_map(|a| Some(a.name.as_ref()?.as_str())).collect();

        let mut string_section = vec![];
        names.sort_by_key(|name| sfat_hash(name));
        let offsets =
            names
                .into_iter()
                .filter_map(|string| {
                    let off = string_section.len() as u32;
                    SarcString::from(string)
                        .write(&mut string_section)
                        .ok()?;
                    Some((sfat_hash(string), off))
                })
                .collect();

        (offsets, string_section)
    }