ok/jj
1
0
Fork 0
forked from mirrors/jj

backend: allow cheap copy of MillisSinceEpoch(i64)

It's unlikely this type will become uncopyable.
This commit is contained in:
Yuya Nishihara 2023-08-12 13:00:13 +09:00
parent ebf90384f6
commit e588a9babc
4 changed files with 4 additions and 5 deletions

View file

@ -39,7 +39,7 @@ id_type!(pub FileId);
id_type!(pub SymlinkId);
id_type!(pub ConflictId);
#[derive(ContentHash, Debug, PartialEq, Eq, Clone, PartialOrd, Ord)]
#[derive(ContentHash, Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
pub struct MillisSinceEpoch(pub i64);
#[derive(ContentHash, Debug, PartialEq, Eq, Clone, PartialOrd, Ord)]

View file

@ -950,7 +950,7 @@ impl<'index> EvaluationContext<'index> {
let make_rev_item = |entry: IndexEntry<'_>| {
let commit = self.store.get_commit(&entry.commit_id()).unwrap();
Reverse(Item {
timestamp: commit.committer().timestamp.timestamp.clone(),
timestamp: commit.committer().timestamp.timestamp,
pos: entry.position(),
})
};

View file

@ -1876,8 +1876,7 @@ mod tests {
commit2.committer.timestamp.timestamp
);
// The rest of the commit should be the same
actual_commit2.committer.timestamp.timestamp =
commit2.committer.timestamp.timestamp.clone();
actual_commit2.committer.timestamp.timestamp = commit2.committer.timestamp.timestamp;
assert_eq!(actual_commit2, commit2);
}

View file

@ -129,7 +129,7 @@ where
return Ok(op_head.clone());
}
op_heads.sort_by_key(|op| op.metadata().end_time.timestamp.clone());
op_heads.sort_by_key(|op| op.metadata().end_time.timestamp);
let new_op = resolver(op_heads)?;
let mut old_op_heads = ancestor_op_heads;
old_op_heads.extend_from_slice(new_op.parent_ids());