mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-18 02:04:19 +00:00
tree: avoid some cloning by passing by value
This commit is contained in:
parent
a87125d08b
commit
cf672de792
1 changed files with 10 additions and 12 deletions
|
@ -626,7 +626,7 @@ fn merge_tree_value(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let filename = dir.join(basename);
|
let filename = dir.join(basename);
|
||||||
let conflict = simplify_conflict(store, &filename, &conflict)?;
|
let conflict = simplify_conflict(store, &filename, conflict)?;
|
||||||
if conflict.adds.is_empty() {
|
if conflict.adds.is_empty() {
|
||||||
// If there are no values to add, then the path doesn't exist
|
// If there are no values to add, then the path doesn't exist
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
|
@ -742,18 +742,16 @@ fn try_resolve_file_conflict(
|
||||||
fn conflict_term_to_conflict(
|
fn conflict_term_to_conflict(
|
||||||
store: &Store,
|
store: &Store,
|
||||||
path: &RepoPath,
|
path: &RepoPath,
|
||||||
term: &ConflictTerm,
|
term: ConflictTerm,
|
||||||
) -> Result<Conflict, BackendError> {
|
) -> Result<Conflict, BackendError> {
|
||||||
match &term.value {
|
match term.value {
|
||||||
TreeValue::Conflict(id) => {
|
TreeValue::Conflict(id) => {
|
||||||
let conflict = store.read_conflict(path, id)?;
|
let conflict = store.read_conflict(path, &id)?;
|
||||||
Ok(conflict)
|
Ok(conflict)
|
||||||
}
|
}
|
||||||
other => Ok(Conflict {
|
other => Ok(Conflict {
|
||||||
removes: vec![],
|
removes: vec![],
|
||||||
adds: vec![ConflictTerm {
|
adds: vec![ConflictTerm { value: other }],
|
||||||
value: other.clone(),
|
|
||||||
}],
|
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -761,7 +759,7 @@ fn conflict_term_to_conflict(
|
||||||
fn simplify_conflict(
|
fn simplify_conflict(
|
||||||
store: &Store,
|
store: &Store,
|
||||||
path: &RepoPath,
|
path: &RepoPath,
|
||||||
conflict: &Conflict,
|
conflict: Conflict,
|
||||||
) -> Result<Conflict, BackendError> {
|
) -> Result<Conflict, BackendError> {
|
||||||
// Important cases to simplify:
|
// Important cases to simplify:
|
||||||
//
|
//
|
||||||
|
@ -797,7 +795,7 @@ fn simplify_conflict(
|
||||||
// First expand any diffs with nested conflicts.
|
// First expand any diffs with nested conflicts.
|
||||||
let mut new_removes = vec![];
|
let mut new_removes = vec![];
|
||||||
let mut new_adds = vec![];
|
let mut new_adds = vec![];
|
||||||
for term in &conflict.adds {
|
for term in conflict.adds {
|
||||||
match term.value {
|
match term.value {
|
||||||
TreeValue::Conflict(_) => {
|
TreeValue::Conflict(_) => {
|
||||||
let conflict = conflict_term_to_conflict(store, path, term)?;
|
let conflict = conflict_term_to_conflict(store, path, term)?;
|
||||||
|
@ -805,11 +803,11 @@ fn simplify_conflict(
|
||||||
new_adds.extend_from_slice(&conflict.adds);
|
new_adds.extend_from_slice(&conflict.adds);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
new_adds.push(term.clone());
|
new_adds.push(term);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for term in &conflict.removes {
|
for term in conflict.removes {
|
||||||
match term.value {
|
match term.value {
|
||||||
TreeValue::Conflict(_) => {
|
TreeValue::Conflict(_) => {
|
||||||
let conflict = conflict_term_to_conflict(store, path, term)?;
|
let conflict = conflict_term_to_conflict(store, path, term)?;
|
||||||
|
@ -817,7 +815,7 @@ fn simplify_conflict(
|
||||||
new_adds.extend_from_slice(&conflict.removes);
|
new_adds.extend_from_slice(&conflict.removes);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
new_removes.push(term.clone());
|
new_removes.push(term);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue