Skip to content

Commit

Permalink
🧹(icu_lib, src): Remove unnecessary references and update function calls
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
W-Mai committed Nov 27, 2024
1 parent 040cf0e commit 5997968
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion icu_lib/src/endecoder/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
6 changes: 3 additions & 3 deletions icu_lib/src/endecoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn process() -> Result<(), Box<dyn std::error::Error>> {
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());

Expand Down Expand Up @@ -129,7 +129,7 @@ fn process() -> Result<(), Box<dyn std::error::Error>> {
)
.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);
Expand Down

0 comments on commit 5997968

Please sign in to comment.