language: Optimize language_for_file (#28671)
While working on #28670 this function showed up in my profiles; this PR makes it evaluate some of it's conditions lazily + prevent constant rebuilding of globset::Candidates. Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
parent
5e57f148ac
commit
98891e4c70
2 changed files with 40 additions and 28 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
use crate::{File, Language, LanguageName, LanguageServerName};
|
||||
use anyhow::Result;
|
||||
use collections::{HashMap, HashSet};
|
||||
use collections::{FxHashMap, HashMap, HashSet};
|
||||
use core::slice;
|
||||
use ec4rs::{
|
||||
Properties as EditorconfigProperties,
|
||||
|
@ -63,7 +63,7 @@ pub struct AllLanguageSettings {
|
|||
pub edit_predictions: EditPredictionSettings,
|
||||
pub defaults: LanguageSettings,
|
||||
languages: HashMap<LanguageName, LanguageSettings>,
|
||||
pub(crate) file_types: HashMap<Arc<str>, GlobSet>,
|
||||
pub(crate) file_types: FxHashMap<Arc<str>, GlobSet>,
|
||||
}
|
||||
|
||||
/// The settings for a particular language.
|
||||
|
@ -1217,7 +1217,7 @@ impl settings::Settings for AllLanguageSettings {
|
|||
.map(|settings| settings.enabled_in_assistant)
|
||||
.unwrap_or(true);
|
||||
|
||||
let mut file_types: HashMap<Arc<str>, GlobSet> = HashMap::default();
|
||||
let mut file_types: FxHashMap<Arc<str>, GlobSet> = FxHashMap::default();
|
||||
|
||||
for (language, suffixes) in &default_value.file_types {
|
||||
let mut builder = GlobSetBuilder::new();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue