mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-27 09:13:21 +03:00
Avoid allocating a string to compare language names
This commit is contained in:
parent
c49dc8d6e5
commit
36e4dcef16
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3157,6 +3157,7 @@ dependencies = [
|
||||
"tree-sitter-ruby",
|
||||
"tree-sitter-rust",
|
||||
"tree-sitter-typescript",
|
||||
"unicase",
|
||||
"unindent",
|
||||
"util",
|
||||
]
|
||||
|
@ -53,6 +53,7 @@ smol = "1.2"
|
||||
tree-sitter = "0.20"
|
||||
tree-sitter-rust = { version = "*", optional = true }
|
||||
tree-sitter-typescript = { version = "*", optional = true }
|
||||
unicase = "2.6"
|
||||
|
||||
[dev-dependencies]
|
||||
client = { path = "../client", features = ["test-support"] }
|
||||
|
@ -41,6 +41,7 @@ use std::{
|
||||
use syntax_map::SyntaxSnapshot;
|
||||
use theme::{SyntaxTheme, Theme};
|
||||
use tree_sitter::{self, Query};
|
||||
use unicase::UniCase;
|
||||
use util::ResultExt;
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
@ -467,10 +468,11 @@ impl LanguageRegistry {
|
||||
}
|
||||
|
||||
pub fn language_for_name(&self, name: &str) -> Option<Arc<Language>> {
|
||||
let name = UniCase::new(name);
|
||||
self.languages
|
||||
.read()
|
||||
.iter()
|
||||
.find(|language| language.name().to_lowercase() == name.to_lowercase())
|
||||
.find(|language| UniCase::new(language.name()) == name)
|
||||
.cloned()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user