From 8ae5842647eb9be63e662d11cea7268f5ecb0202 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 6 Jun 2026 19:52:20 +0900 Subject: refactor(perforce): drop stale TODO comment The OnceLock already emulates PHP's function-local `static $p4Executable;` (compute once, cache for the process lifetime, shared across instances). Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/util/perforce.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'crates/shirabe/src/util/perforce.rs') diff --git a/crates/shirabe/src/util/perforce.rs b/crates/shirabe/src/util/perforce.rs index cd384fc..d84e4ea 100644 --- a/crates/shirabe/src/util/perforce.rs +++ b/crates/shirabe/src/util/perforce.rs @@ -842,14 +842,12 @@ impl Perforce { } fn get_p4_executable() -> String { - // TODO(phase-b): emulate PHP `static $p4Executable;` — cache across calls static P4_EXECUTABLE: std::sync::OnceLock = std::sync::OnceLock::new(); + P4_EXECUTABLE .get_or_init(|| { let finder = ExecutableFinder::new(); - finder - .find("p4", None, &[]) - .unwrap_or_else(|| "p4".to_string()) + finder.find("p4", None, &[]).unwrap_or("p4".to_string()) }) .clone() } -- cgit v1.3.1