Skip to main content

luaur_ast/methods/
ast_name_table_entry_hash_operator_call.rs

1use crate::records::entry::Entry;
2use crate::records::entry_hash::EntryHash;
3
4impl EntryHash {
5    #[allow(non_snake_case)]
6    pub fn operator_call(&self, e: &Entry) -> usize {
7        // FNV1a
8        let mut hash: u32 = 2166136261;
9
10        for i in 0..e.length as usize {
11            unsafe {
12                let byte = *e.value.value.add(i) as u8;
13                hash ^= byte as u32;
14                hash = hash.wrapping_mul(16777619);
15            }
16        }
17
18        hash as usize
19    }
20}
21
22#[allow(non_snake_case)]
23pub fn ast_name_table_entry_hash_operator_call(this: &EntryHash, e: &Entry) -> usize {
24    this.operator_call(e)
25}