on master help sign in
only fetch git-sourced grammars

This is a bit of a micro-optimization: in the current setup we waste a thread in the pool for a local grammar only to println! a message saying we're skipping fetching because it's a local grammar.

commit6fcab90d16f9493c0c4738312061a26e473ab12a authorMichael Davis <mcarsondavis@gmail.com> dateSat 19 Feb 2022, 04:51 (5 years ago) parenta229f40
1 file changed+7−6
helix-loader/src/grammar.rs+7−6
helix-loader/src/grammar.rs+7−6
@@ -76,7 +76,11 @@ pub fn get_language(name: &str) -> Result<Language> {
7676}
7777
7878pub fn fetch_grammars() -> Result<()> {
79− run_parallel(get_grammar_configs()?, fetch_grammar, "fetch")
79+ // We do not need to fetch local grammars.
80+ let mut grammars = get_grammar_configs()?;
81+ grammars.retain(|grammar| !matches!(grammar.source, GrammarSource::Local { .. }));
82+
83+ run_parallel(grammars, fetch_grammar, "fetch")
8084}
8185
8286pub fn build_grammars() -> Result<()> {
@@ -172,15 +176,12 @@ fn fetch_grammar(grammar: GrammarConfiguration) -> Result<()> {
172176 "Grammar '{}' checked out at '{}'.",
173177 grammar.grammar_id, revision
174178 );
175− Ok(())
176179 } else {
177180 println!("Grammar '{}' is already up to date.", grammar.grammar_id);
178− Ok(())
179181 }
180− } else {
181− println!("Skipping local grammar '{}'", grammar.grammar_id);
182− Ok(())
183182 }
183+
184+ Ok(())
184185}
185186
186187// Sets the remote for a repository to the given URL, creating the remote if