Skip to content

Commit

Permalink
identity: move "SL_GIT" ident to outside "all()"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
quark-zju authored and facebook-github-bot committed Mar 1, 2024
1 parent c483f72 commit 13a0b1a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions eden/scm/lib/identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ mod idents {
use super::*;

pub fn all() -> &'static [Identity] {
&[SL, HG, SL_GIT]
&[SL, HG]
}
}

Expand All @@ -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] }
}
}

Expand All @@ -456,6 +452,8 @@ pub mod idents {
}
}

static EXTRA_SNIFF_IDENTS: &'static [Identity] = &[SL_GIT];

static INITIAL_DEFAULT: Lazy<Identity> = Lazy::new(compute_default);
static DEFAULT: Lazy<RwLock<Identity>> = Lazy::new(|| RwLock::new(*INITIAL_DEFAULT));

Expand Down Expand Up @@ -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<Option<Identity>> {
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;
Expand Down

0 comments on commit 13a0b1a

Please sign in to comment.