From 89a0f46986a06ae8ae69cb4afd45f810f9219eec Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 27 Oct 2024 19:52:46 +0900 Subject: [PATCH] annotate: remove redundant .is_absent() test from get_file_contents() Here we shouldn't care whether the file value is absent or a tree, for example. --- lib/src/annotate.rs | 52 +++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/lib/src/annotate.rs b/lib/src/annotate.rs index 0f6c94f64f..8723761074 100644 --- a/lib/src/annotate.rs +++ b/lib/src/annotate.rs @@ -251,34 +251,30 @@ fn get_file_contents( tree: &MergedTree, ) -> Result, BackendError> { let file_value = tree.path_value(path)?; - if file_value.is_absent() { - Ok(Vec::new()) - } else { - let effective_file_value = materialize_tree_value(store, path, file_value).block_on()?; - match effective_file_value { - MaterializedTreeValue::File { mut reader, id, .. } => { - let mut file_contents = Vec::new(); - reader - .read_to_end(&mut file_contents) - .map_err(|e| BackendError::ReadFile { - path: path.to_owned(), - id, - source: Box::new(e), - })?; - Ok(file_contents) - } - MaterializedTreeValue::FileConflict { id, contents, .. } => { - let mut materialized_conflict_buffer = Vec::new(); - materialize_merge_result(&contents, &mut materialized_conflict_buffer).map_err( - |io_err| BackendError::ReadFile { - path: path.to_owned(), - source: Box::new(io_err), - id: id.first().clone().unwrap(), - }, - )?; - Ok(materialized_conflict_buffer) - } - _ => Ok(Vec::new()), + let effective_file_value = materialize_tree_value(store, path, file_value).block_on()?; + match effective_file_value { + MaterializedTreeValue::File { mut reader, id, .. } => { + let mut file_contents = Vec::new(); + reader + .read_to_end(&mut file_contents) + .map_err(|e| BackendError::ReadFile { + path: path.to_owned(), + id, + source: Box::new(e), + })?; + Ok(file_contents) + } + MaterializedTreeValue::FileConflict { id, contents, .. } => { + let mut materialized_conflict_buffer = Vec::new(); + materialize_merge_result(&contents, &mut materialized_conflict_buffer).map_err( + |io_err| BackendError::ReadFile { + path: path.to_owned(), + source: Box::new(io_err), + id: id.first().clone().unwrap(), + }, + )?; + Ok(materialized_conflict_buffer) } + _ => Ok(Vec::new()), } }