Skip to main content

luaur_analysis/methods/
hash_luau_symbol_operator_call.rs

1use crate::records::symbol::Symbol;
2use core::hash::{Hash, Hasher};
3
4impl Symbol {
5    pub fn hash_luau_symbol_operator_call(&self) -> usize {
6        let mut hasher = std::collections::hash_map::DefaultHasher::new();
7
8        // std::hash<const Luau::AstLocal*>()(s.local)
9        self.local.hash(&mut hasher);
10        let mut h = hasher.finish() as usize;
11
12        // (s.global.value ? std::hash<std::string_view>()(s.global.value) : 0)
13        if !self.global.value.is_null() {
14            let mut name_hasher = std::collections::hash_map::DefaultHasher::new();
15            let s = unsafe { core::ffi::CStr::from_ptr(self.global.value).to_bytes() };
16            s.hash(&mut name_hasher);
17            h ^= name_hasher.finish() as usize;
18        }
19
20        h
21    }
22}