From 4f5f290514375231e6cc8a05f22694bee194c563 Mon Sep 17 00:00:00 2001 From: cschantz Date: Mon, 2 Mar 2026 22:27:07 -0500 Subject: [PATCH] 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 --- modules/website/wordpress/wordpress-cron-manager.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/website/wordpress/wordpress-cron-manager.sh b/modules/website/wordpress/wordpress-cron-manager.sh index e468b83..0fadaa1 100755 --- a/modules/website/wordpress/wordpress-cron-manager.sh +++ b/modules/website/wordpress/wordpress-cron-manager.sh @@ -528,8 +528,9 @@ cron_job_exists() { disable_wp_cron_exists() { local wp_config="$1" + # OPTIMIZATION: Single grep instead of double-pipe # 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)