From e5b49c7d522c85dff257fd3f1d96ccf67aa28126 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 17 Jul 2024 20:50:47 +0900 Subject: [PATCH] files: extract pre-processing part from merge() I'll make the first half generic over T: AsRef<[u8]>. --- lib/src/files.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/files.rs b/lib/src/files.rs index 588337bb2..d623efc9b 100644 --- a/lib/src/files.rs +++ b/lib/src/files.rs @@ -162,8 +162,10 @@ pub fn merge(slices: &Merge<&[u8]>) -> MergeResult { // more than 3 parts? let num_diffs = slices.removes().len(); let diff_inputs = slices.removes().chain(slices.adds()); + merge_hunks(&Diff::by_line(diff_inputs), num_diffs) +} - let diff = Diff::by_line(diff_inputs); +fn merge_hunks(diff: &Diff, num_diffs: usize) -> MergeResult { let mut resolved_hunk = ContentHunk(vec![]); let mut merge_hunks: Vec> = vec![]; for diff_hunk in diff.hunks() {