swc_ecma_preset_env/
util.rs1pub(crate) struct SwcFold;
2
3impl precomputed_map::phf::HashOne for SwcFold {
4 fn hash_one<T: std::hash::Hash>(k: u64, v: T) -> u64 {
5 use std::hash::Hasher;
6
7 let mut hasher =
8 foldhash::fast::FoldHasher::with_seed(k, foldhash::SharedSeed::global_fixed());
9 v.hash(&mut hasher);
10 hasher.finish()
11 }
12}
13
14#[derive(Clone, Copy)]
15pub(crate) struct PooledStr(pub(crate) u32);
16
17impl PooledStr {
18 pub fn as_str(self) -> &'static str {
19 const STRPOOL: &str = include_str!(concat!(env!("OUT_DIR"), "/str.bin"));
20
21 let offset = self.0 & ((1 << 24) - 1);
22 let len = self.0 >> 24;
23 &STRPOOL[offset as usize..][..len as usize]
24 }
25}