From 13a0b1a8e40f6dd44fb979738b731d959c1d27f8 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Thu, 29 Feb 2024 18:46:19 -0800 Subject: [PATCH] identity: move "SL_GIT" ident to outside "all()" Summary: The "SL_GIT" ident is only used by "sniff_dir". Other references of "all()" expect different user identities. Move it to only affect "sniff_dir" to reduce overhead. Reviewed By: muirdm Differential Revision: D54218753 fbshipit-source-id: dddc796e46738839fb2c6c17051c7a082fe7d6cc --- eden/scm/lib/identity/src/lib.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/eden/scm/lib/identity/src/lib.rs b/eden/scm/lib/identity/src/lib.rs index 4742f159b7afb..41e2a0c2c0ef3 100644 --- a/eden/scm/lib/identity/src/lib.rs +++ b/eden/scm/lib/identity/src/lib.rs @@ -430,7 +430,7 @@ mod idents { use super::*; pub fn all() -> &'static [Identity] { - &[SL, HG, SL_GIT] + &[SL, HG] } } @@ -439,11 +439,7 @@ mod idents { use super::*; pub fn all() -> &'static [Identity] { - if in_test() { - &[SL, HG, SL_GIT] - } else { - &[SL, SL_GIT] - } + if in_test() { &[SL, HG] } else { &[SL] } } } @@ -456,6 +452,8 @@ pub mod idents { } } +static EXTRA_SNIFF_IDENTS: &'static [Identity] = &[SL_GIT]; + static INITIAL_DEFAULT: Lazy = Lazy::new(compute_default); static DEFAULT: Lazy> = Lazy::new(|| RwLock::new(*INITIAL_DEFAULT)); @@ -524,7 +522,7 @@ pub fn cli_name() -> &'static str { /// "{path}/.sl" directories, yielding the sniffed Identity, if any. /// Only permissions errors are propagated. pub fn sniff_dir(path: &Path) -> Result> { - for id in all() { + for id in all().iter().chain(EXTRA_SNIFF_IDENTS) { if let Some(cli_names) = id.repo.sniff_initial_cli_names { if !cli_names.contains(INITIAL_DEFAULT.cli_name()) { continue;