Replace external dirname/basename with parameter expansion in hot loops
lidarr_missing_art.sh's album-directory-map loop (both the cache-hit and live-fallback branches) and arr_profile_enforcer.sh's _is_kids_path() called dirname/basename once per item -- 127K+ tracks and ~4000 series/movies respectively, each call forking a subprocess. Measured: 0.39s vs 72.2s for 20K calls, ~185x. Verified identical output against real paths (including unicode/space/paren edge cases) before switching.
This commit is contained in:
@@ -104,8 +104,11 @@ exit(1);
|
||||
|
||||
_is_kids_path() {
|
||||
local path="$1"
|
||||
local dir
|
||||
dir=$(basename "$(dirname "$path")")
|
||||
# Parameter expansion instead of external dirname+basename — called once per series/movie
|
||||
# (~4000 items combined), each call was forking two subprocesses. Measured 2026-07-17:
|
||||
# ~185x faster per equivalent call (0.39s vs 72.2s per 20K) for the identical result.
|
||||
local parent="${path%/*}"
|
||||
local dir="${parent##*/}"
|
||||
[[ "$dir" == *kids* || "$dir" == *anime* ]]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user