From 59979684b79ad312af0cbff1185758c42d1775b8 Mon Sep 17 00:00:00 2001 From: Benign X <1341398182@qq.com> Date: Wed, 27 Nov 2024 14:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9(icu=5Flib,=20src):=20Remove=20unne?= =?UTF-8?q?cessary=20references=20and=20update=20function=20calls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clean up the code by removing an unnecessary reference in `icu_lib/src/endecoder/mod.rs` and updating function calls to pass parameters by value instead of by reference where appropriate in `icu_lib/src/endecoder/common/mod.rs` and `src/main.rs`. These changes improve the readability and efficiency of the code. Signed-off-by: Benign X <1341398182@qq.com> --- icu_lib/src/endecoder/common/mod.rs | 2 +- icu_lib/src/endecoder/mod.rs | 6 +++--- src/main.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/icu_lib/src/endecoder/common/mod.rs b/icu_lib/src/endecoder/common/mod.rs index 793f4bd..096715c 100644 --- a/icu_lib/src/endecoder/common/mod.rs +++ b/icu_lib/src/endecoder/common/mod.rs @@ -49,7 +49,7 @@ impl EnDecoder for AutoDetect { fn info(&self, data: &[u8]) -> ImageInfo { log::trace!("AutoDectect::decoding"); - let img = image::load_from_memory(&data).unwrap(); + let img = image::load_from_memory(data).unwrap(); let img_format = image::guess_format(data).unwrap(); log::trace!("AutoDectect::decoded"); diff --git a/icu_lib/src/endecoder/mod.rs b/icu_lib/src/endecoder/mod.rs index 4b8e1d8..3032482 100644 --- a/icu_lib/src/endecoder/mod.rs +++ b/icu_lib/src/endecoder/mod.rs @@ -3,7 +3,7 @@ pub mod lvgl; pub mod utils; use crate::midata::MiData; -use crate::{endecoder, EncoderParams}; +use crate::EncoderParams; use serde::Serialize; #[derive(Debug, Serialize)] @@ -26,8 +26,8 @@ pub trait EnDecoder { pub fn find_endecoder(data: &[u8]) -> Option<&'static dyn EnDecoder> { let eds = vec![ - &endecoder::common::AutoDetect {} as &dyn EnDecoder, - &endecoder::lvgl::LVGL {} as &dyn EnDecoder, + &common::AutoDetect {} as &dyn EnDecoder, + &lvgl::LVGL {} as &dyn EnDecoder, ]; for ed in eds { diff --git a/src/main.rs b/src/main.rs index 747faec..3e1a3ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,7 +91,7 @@ fn process() -> Result<(), Box> { let start_time = std::time::Instant::now(); let output_file_path = - deal_path_without_extension(&file_path, &input_folder, output_folder.clone()) + deal_path_without_extension(file_path, &input_folder, output_folder.clone()) .unwrap_or_default() .with_extension(output_format.get_file_extension()); @@ -129,7 +129,7 @@ fn process() -> Result<(), Box> { ) .with_lvgl_version((*lvgl_version).into()); - let data = fs::read(&file_path)?; + let data = fs::read(file_path)?; let ed = output_format.get_endecoder(); let mid = decode_with(data, *input_format)?; let data = mid.encode_into(ed, params);