feat: intern cell keys for O(1) comparison and indexing
Refactor DataStore to use interned keys (InternedKey) instead of string-based CellKey for O(1) hash and compare operations. Introduce SymbolTable-backed interning for all category and item names, storing them as Symbol identifiers throughout the data structure. Add secondary index mapping (category, item) pairs to sets of interned keys, enabling efficient partial match queries without scanning all cells. Optimize matching_values() to avoid allocating CellKey strings by working directly with interned keys and intersecting index sets. Update all callers to use new API: iter_cells(), matching_values(), and internal lookup_key() helper. Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
@ -88,7 +88,7 @@ pub fn format_md(model: &Model) -> String {
|
||||
}
|
||||
|
||||
// Data — sorted by coordinate string for deterministic diffs
|
||||
let mut cells: Vec<_> = model.data.cells().iter().collect();
|
||||
let mut cells: Vec<_> = model.data.iter_cells().collect();
|
||||
cells.sort_by_key(|(k, _)| coord_str(k));
|
||||
if !cells.is_empty() {
|
||||
writeln!(out, "\n## Data").unwrap();
|
||||
@ -97,7 +97,7 @@ pub fn format_md(model: &Model) -> String {
|
||||
CellValue::Number(_) => value.to_string(),
|
||||
CellValue::Text(s) => format!("\"{}\"", s),
|
||||
};
|
||||
writeln!(out, "{} = {}", coord_str(key), val_str).unwrap();
|
||||
writeln!(out, "{} = {}", coord_str(&key), val_str).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,7 +461,7 @@ pub fn export_csv(model: &Model, view_name: &str, path: &Path) -> Result<()> {
|
||||
.map(|ci| {
|
||||
layout
|
||||
.cell_key(ri, ci)
|
||||
.and_then(|key| model.evaluate(&key))
|
||||
.and_then(|key| model.evaluate_aggregated(&key, &layout.none_cats))
|
||||
.map(|v| v.to_string())
|
||||
.unwrap_or_default()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user