mirror of
https://github.com/tw93/Mole.git
synced 2026-02-12 16:20:14 +00:00
perf: skip redundant -name parameter when pattern is wildcard
Optimization: - Skip -name "*" in safe_sudo_find_delete when pattern matches everything - Reduces unnecessary parameter passing to find command - Improves performance for operations that scan all files Rationale: - find -name "*" is redundant as it matches everything by default - Removing it reduces command overhead without changing behavior
This commit is contained in:
@@ -467,7 +467,12 @@ safe_sudo_find_delete() {
|
|||||||
|
|
||||||
debug_log "Finding, sudo, in $base_dir: $pattern, age: ${age_days}d, type: $type_filter"
|
debug_log "Finding, sudo, in $base_dir: $pattern, age: ${age_days}d, type: $type_filter"
|
||||||
|
|
||||||
local find_args=("-maxdepth" "5" "-name" "$pattern" "-type" "$type_filter")
|
local find_args=("-maxdepth" "5")
|
||||||
|
# Skip -name if pattern is "*" (matches everything anyway, but adds overhead)
|
||||||
|
if [[ "$pattern" != "*" ]]; then
|
||||||
|
find_args+=("-name" "$pattern")
|
||||||
|
fi
|
||||||
|
find_args+=("-type" "$type_filter")
|
||||||
if [[ "$age_days" -gt 0 ]]; then
|
if [[ "$age_days" -gt 0 ]]; then
|
||||||
find_args+=("-mtime" "+$age_days")
|
find_args+=("-mtime" "+$age_days")
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user