From 0dbd3094ec2fe7152e1524b2e395a4e1f40de717 Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Mon, 6 Jan 2025 18:20:18 +0800 Subject: [PATCH] hbb_common: simplify is_compressed_file (#10436) * hbb_common: simplify is_compressed_file Signed-off-by: Xiaobo Liu * `exts` rename to `compressed_exts` --------- Signed-off-by: Xiaobo Liu --- libs/hbb_common/src/fs.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libs/hbb_common/src/fs.rs b/libs/hbb_common/src/fs.rs index 2605f304e73c..1488ffd93cf7 100644 --- a/libs/hbb_common/src/fs.rs +++ b/libs/hbb_common/src/fs.rs @@ -303,16 +303,9 @@ fn get_ext(name: &str) -> &str { #[inline] fn is_compressed_file(name: &str) -> bool { + let compressed_exts = ["xz", "gz", "zip", "7z", "rar", "bz2", "tgz", "png", "jpg"]; let ext = get_ext(name); - ext == "xz" - || ext == "gz" - || ext == "zip" - || ext == "7z" - || ext == "rar" - || ext == "bz2" - || ext == "tgz" - || ext == "png" - || ext == "jpg" + compressed_exts.contains(&ext) } impl TransferJob {