index: make CompositeIndex copyable to clarify it is a cheap reference type

Well, I might change it to an owned wrapper later, but if I made such change,
the current CompositeIndex<'_> would be replaced with &CompositeIndex.
This commit is contained in:
Yuya Nishihara 2023-05-26 08:11:52 +09:00
parent d047a8fbd4
commit 92c1b7091b
2 changed files with 5 additions and 5 deletions

View file

@ -826,7 +826,7 @@ trait IndexSegment: Send + Sync {
fn segment_entry_by_pos(&self, pos: IndexPosition, local_pos: u32) -> IndexEntry;
}
#[derive(Clone)]
#[derive(Clone, Copy)]
pub struct CompositeIndex<'a>(&'a dyn IndexSegment);
impl<'a> CompositeIndex<'a> {
@ -1052,7 +1052,7 @@ impl<'a> CompositeIndex<'a> {
}
pub fn walk_revs(&self, wanted: &[CommitId], unwanted: &[CommitId]) -> RevWalk<'a> {
let mut rev_walk = RevWalk::new(self.clone());
let mut rev_walk = RevWalk::new(*self);
for pos in wanted.iter().map(|id| self.commit_id_to_pos(id).unwrap()) {
rev_walk.add_wanted(pos);
}
@ -1426,7 +1426,7 @@ impl<'a> RevWalk<'a> {
root_positions: &[IndexPosition],
generation_range: Range<u32>,
) -> RevWalkDescendantsGenerationRange<'a> {
let index = self.0.queue.index.clone();
let index = self.0.queue.index;
let entries = self.take_until_roots(root_positions);
let descendants_index = RevWalkDescendantsIndex::build(index, entries);
let mut queue = RevWalkQueue::new(descendants_index);

View file

@ -113,7 +113,7 @@ impl<'index> Revset<'index> for RevsetImpl<'index> {
}
let pos_by_change = IdIndex::from_vec(pos_by_change);
Box::new(ChangeIdIndexImpl {
index: self.index.clone(),
index: self.index,
pos_by_change,
})
}
@ -492,7 +492,7 @@ pub fn evaluate<'index>(
let context = EvaluationContext {
store: store.clone(),
index,
composite_index: composite_index.clone(),
composite_index,
};
let internal_revset = context.evaluate(expression)?;
Ok(RevsetImpl::new(internal_revset, composite_index))