From ba9c762797746900eed8ee362ac2382a6058ea24 Mon Sep 17 00:00:00 2001 From: tommady Date: Fri, 24 Feb 2023 02:40:50 +0000 Subject: [PATCH] address comment with using the binary search --- src/info/filetype.rs | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/info/filetype.rs b/src/info/filetype.rs index 3011cd65..a241c574 100644 --- a/src/info/filetype.rs +++ b/src/info/filetype.rs @@ -23,14 +23,42 @@ impl FileExtensions { fn is_immediate(&self, file: &File<'_>) -> bool { file.name.to_lowercase().starts_with("readme") || file.name.ends_with(".ninja") || - file.name_is_one_of( &[ - "GNUmakefile", "Makefile", "makefile", "Cargo.toml", "SConstruct", "CMakeLists.txt", - "build.gradle", "pom.xml", "Rakefile", "package.json", "Gruntfile.js", - "Gruntfile.coffee", "BUILD", "BUILD.bazel", "WORKSPACE", "build.xml", "Podfile", - "webpack.config.js", "meson.build", "composer.json", "RoboFile.php", "PKGBUILD", - "Justfile", "Procfile", "Dockerfile", "Containerfile", "Vagrantfile", "Brewfile", - "Gemfile", "Pipfile", "build.sbt", "mix.exs", "bsconfig.json", "tsconfig.json", - ]) + [ + "BUILD", + "BUILD.bazel", + "Brewfile", + "CMakeLists.txt", + "Cargo.toml", + "Containerfile", + "Dockerfile", + "GNUmakefile", + "Gemfile", + "Gruntfile.coffee", + "Gruntfile.js", + "Justfile", + "Makefile", + "PKGBUILD", + "Pipfile", + "Podfile", + "Procfile", + "Rakefile", + "RoboFile.php", + "SConstruct", + "Vagrantfile", + "WORKSPACE", + "bsconfig.json", + "build.gradle", + "build.sbt", + "build.xml", + "composer.json", + "makefile", + "meson.build", + "mix.exs", + "package.json", + "pom.xml", + "tsconfig.json", + "webpack.config.js", + ].binary_search(&file.name.as_str()).is_ok() } fn is_image(&self, file: &File<'_>) -> bool {