diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-06 19:52:20 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-06 19:52:37 +0900 |
| commit | 8ae5842647eb9be63e662d11cea7268f5ecb0202 (patch) | |
| tree | aa91a2279bc1321cd36dc8f7a1b3406d0cb15ac1 /crates | |
| parent | af4b9fcba1206e3fcc97fc243ffc674f85547942 (diff) | |
| download | php-shirabe-8ae5842647eb9be63e662d11cea7268f5ecb0202.tar.gz php-shirabe-8ae5842647eb9be63e662d11cea7268f5ecb0202.tar.zst php-shirabe-8ae5842647eb9be63e662d11cea7268f5ecb0202.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/shirabe/src/util/perforce.rs | 6 |
1 files changed, 2 insertions, 4 deletions
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<String> = 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() } |
