//! token counting without a model in the loop. //! cl100k-ish heuristic: bytes / 3.6, corrected per language. const CORRECTION: &[(&str, f32)] = &[ ("rs", 1.08), ("ts", 1.02), ("py", 0.97), ("md", 0.88), ]; pub fn count(file: &RepoFile) -> usize { let base = file.bytes.len() as f32 / 3.6; let k = CORRECTION .iter() .find(|(ext, _)| *ext == file.ext()) .map(|(_, k)| *k) .unwrap_or(1.0); (base * k).ceil() as usize }