config: lazyily produce ssh domain list
I noticed that in debug builds, `wezterm set-working-directory` had high/variable latency, and I traced part of it to the ssh config parsing logic. Make that lazily evaluate the ssh config. refs: #3402
This commit is contained in:
2 files changed
+19
-6
No files matched your search
+17
-4
@@ -325,8 +325,8 @@ pub struct Config {
|
||||
#[dynamic(default = "UnixDomain::default_unix_domains")]
|
||||
pub unix_domains: Vec<UnixDomain>,
|
||||
|
||||
#[dynamic(default = "SshDomain::default_domains")]
|
||||
pub ssh_domains: Vec<SshDomain>,
|
||||
#[dynamic(default)]
|
||||
pub ssh_domains: Option<Vec<SshDomain>>,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub ssh_backend: SshBackend,
|
||||
@@ -828,6 +828,17 @@ impl Config {
|
||||
Self::load_with_overrides(&wezterm_dynamic::Value::default())
|
||||
}
|
||||
|
||||
/// It is relatively expensive to parse all the ssh config files,
|
||||
/// so we defer producing the default list until someone explicitly
|
||||
/// asks for it
|
||||
pub fn ssh_domains(&self) -> Vec<SshDomain> {
|
||||
if let Some(domains) = &self.ssh_domains {
|
||||
domains.clone()
|
||||
} else {
|
||||
SshDomain::default_domains()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_ulimit(&self) -> anyhow::Result<()> {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
@@ -1127,8 +1138,10 @@ impl Config {
|
||||
for d in &self.unix_domains {
|
||||
check_domain(&d.name, "unix domain")?;
|
||||
}
|
||||
for d in &self.ssh_domains {
|
||||
check_domain(&d.name, "ssh domain")?;
|
||||
if let Some(domains) = &self.ssh_domains {
|
||||
for d in domains {
|
||||
check_domain(&d.name, "ssh domain")?;
|
||||
}
|
||||
}
|
||||
for d in &self.exec_domains {
|
||||
check_domain(&d.name, "exec domain")?;
|
||||
|
||||
@@ -250,7 +250,7 @@ fn client_domains(config: &config::ConfigHandle) -> Vec<ClientDomainConfig> {
|
||||
domains.push(ClientDomainConfig::Unix(unix_dom.clone()));
|
||||
}
|
||||
|
||||
for ssh_dom in &config.ssh_domains {
|
||||
for ssh_dom in config.ssh_domains().into_iter() {
|
||||
if ssh_dom.multiplexing == SshMultiplexing::WezTerm {
|
||||
domains.push(ClientDomainConfig::Ssh(ssh_dom.clone()));
|
||||
}
|
||||
@@ -341,7 +341,7 @@ fn update_mux_domains(config: &ConfigHandle) -> anyhow::Result<()> {
|
||||
mux.add_domain(&domain);
|
||||
}
|
||||
|
||||
for ssh_dom in &config.ssh_domains {
|
||||
for ssh_dom in config.ssh_domains().into_iter() {
|
||||
if ssh_dom.multiplexing != SshMultiplexing::None {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user