MCPcopy Create free account
hub / github.com/argumentcomputer/ix / visit

Function visit

crates/ixon/src/sharing.rs:355–377  ·  view source on GitHub ↗
(
    hash: blake3::Hash,
    info_map: &HashMap<blake3::Hash, SubtermInfo>,
    state: &mut HashMap<blake3::Hash, VisitState>,
    result: &mut Vec<blake3::Hash>,
  )

Source from the content-addressed store, hash-verified

353 let term_size = *effective_sizes.get(hash)?;
354 let n = info.usage_count;
355 let potential = (n as isize - 1) * (term_size as isize) - (n as isize);
356 if potential > 0 { Some((term_size, n)) } else { None }
357 })
358 .collect();
359
360 candidates.sort_unstable_by(|a, b| {
361 let pot_a = (a.1 as isize - 1) * (a.0 as isize);
362 let pot_b = (b.1 as isize - 1) * (b.0 as isize);
363 pot_b.cmp(&pot_a)
364 });
365
366 for (term_size, usage_count) in candidates {
367 let next_ref_size =
368 Tag4::new(Expr::FLAG_SHARE, simulated_shared as u64).encoded_size();
369 let n = usage_count as isize;
370 let savings = (n - 1) * (term_size as isize) - n * (next_ref_size as isize);
371 if savings > 0 {
372 simulated_shared += 1;
373 }
374 // Don't break - process all candidates
375 }
376
377 SharingStats {
378 total_subterms,
379 unique_subterms,
380 shared_subterms,

Callers 1

topological_sortFunction · 0.70

Calls 3

pushMethod · 0.80
getMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected