Skip to content

Commit

Permalink
refactor(depth_map): simplify stack handling by removing raw segment …
Browse files Browse the repository at this point in the history
…dependency
  • Loading branch information
gvozdvmozgu authored and benfdking committed Nov 30, 2024
1 parent 602404d commit 44aa417
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions crates/lib/src/utils/reflow/depth_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl DepthMap {
fn new<'a>(raws_with_stack: impl Iterator<Item = &'a (ErasedSegment, Vec<PathStep>)>) -> Self {
let depth_info = raws_with_stack
.into_iter()
.map(|(raw, stack)| (raw.id(), DepthInfo::from_raw_and_stack(raw, stack)))
.map(|(raw, stack)| (raw.id(), DepthInfo::from_stack(stack)))
.collect();
Self { depth_info }
}
Expand Down Expand Up @@ -88,7 +88,7 @@ impl DepthMap {
.into_iter()
.map(|raw| {
let stack = root_segment.path_to(&raw);
(raw.id(), DepthInfo::from_raw_and_stack(&raw, &stack))
(raw.id(), DepthInfo::from_stack(&stack))
})
.collect();

Expand All @@ -108,8 +108,7 @@ pub struct DepthInfo {
}

impl DepthInfo {
#[allow(unused_variables)]
fn from_raw_and_stack(raw: &ErasedSegment, stack: &[PathStep]) -> DepthInfo {
fn from_stack(stack: &[PathStep]) -> DepthInfo {
let stack_hashes: Vec<u64> = stack.iter().map(|ps| ps.segment.hash_value()).collect();
let stack_hash_set: IntSet<u64> = IntSet::from_iter(stack_hashes.clone());

Expand Down Expand Up @@ -172,7 +171,7 @@ impl DepthInfo {

let common_hashes: AHashSet<_> = self
.stack_hash_set
.intersection(&other.stack_hashes.iter().copied().collect())
.intersection(&other.stack_hash_set)
.copied()
.collect();

Expand Down

0 comments on commit 44aa417

Please sign in to comment.