OPTIMIZATION: Reduce double-pipe grep operations

Simplified disable_wp_cron_exists() to use single grep instead of piping.

Before:
  grep -E "pattern" file | grep -q "true"

After:
  grep -E "pattern.*true" file

Impact:
- One less grep process spawned
- Cleaner, more readable code
- Negligible performance gain but better practice

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
cschantz
2026-03-02 22:27:07 -05:00
parent 1d8c9237ca
commit 4f5f290514
@@ -528,8 +528,9 @@ cron_job_exists() {
disable_wp_cron_exists() { disable_wp_cron_exists() {
local wp_config="$1" local wp_config="$1"
# OPTIMIZATION: Single grep instead of double-pipe
# Look for uncommented define() call with DISABLE_WP_CRON and true # Look for uncommented define() call with DISABLE_WP_CRON and true
grep -E "^\s*define\s*\(\s*['\"]$WP_CRON_DISABLED_VAR['\"]" "$wp_config" 2>/dev/null | grep -q "true" && return 0 || return 1 grep -E "^\s*define\s*\(\s*['\"]$WP_CRON_DISABLED_VAR['\"].*true" "$wp_config" >/dev/null 2>&1 && return 0 || return 1
} }
# OPTIMIZATION: Cleaner alias for disable_wp_cron_exists (more intuitive name) # OPTIMIZATION: Cleaner alias for disable_wp_cron_exists (more intuitive name)