Skip to content

Commit 1158582

Browse files
committed
index: pass Vec<IndexPosition> to common_ancestors_pos()
All callers build Vec<_>. Since this is an internal API, it doesn't have to be "nice".
1 parent f9c34a6 commit 1158582

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/src/default_index/composite.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,11 @@ impl CompositeIndex {
317317
/// The returned index positions are sorted in descending order.
318318
pub(super) fn common_ancestors_pos(
319319
&self,
320-
set1: &[IndexPosition],
321-
set2: &[IndexPosition],
320+
set1: Vec<IndexPosition>,
321+
set2: Vec<IndexPosition>,
322322
) -> Vec<IndexPosition> {
323-
let mut items1: BinaryHeap<_> = set1.iter().copied().collect();
324-
let mut items2: BinaryHeap<_> = set2.iter().copied().collect();
323+
let mut items1 = BinaryHeap::from(set1);
324+
let mut items2 = BinaryHeap::from(set2);
325325
let mut result = Vec::new();
326326
while let (Some(&pos1), Some(&pos2)) = (items1.peek(), items2.peek()) {
327327
match pos1.cmp(&pos2) {
@@ -467,7 +467,7 @@ impl Index for &CompositeIndex {
467467
.iter()
468468
.map(|id| self.commit_id_to_pos(id).unwrap())
469469
.collect_vec();
470-
self.common_ancestors_pos(&pos1, &pos2)
470+
self.common_ancestors_pos(pos1, pos2)
471471
.iter()
472472
.map(|pos| self.entry_by_pos(*pos).commit_id())
473473
.collect()

lib/src/default_index/revset_engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ impl EvaluationContext<'_> {
964964
};
965965
let mut positions = vec![position?];
966966
for position in expression_positions_iter {
967-
positions = index.common_ancestors_pos(&positions, &[position?]);
967+
positions = index.common_ancestors_pos(positions, vec![position?]);
968968
}
969969
Ok(Box::new(EagerRevset { positions }))
970970
}

0 commit comments

Comments
 (0)