diff options
author | Lukas Wirth <[email protected]> | 2021-03-17 10:22:40 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-03-17 10:22:40 +0000 |
commit | cdfb5c353f09138540ae66a2eb80a6a81802bbd6 (patch) | |
tree | 3fac436573b616e090565c38e232e49ad6f2b8d7 /crates/ide/src/syntax_highlighting | |
parent | c766492d2625dba65c3bd933841c71938f6dc747 (diff) |
Remove quadratic attr source lookup
Diffstat (limited to 'crates/ide/src/syntax_highlighting')
-rw-r--r-- | crates/ide/src/syntax_highlighting/inject.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs index 0f1de4fb8..d4c367f66 100644 --- a/crates/ide/src/syntax_highlighting/inject.rs +++ b/crates/ide/src/syntax_highlighting/inject.rs | |||
@@ -153,6 +153,7 @@ pub(super) fn doc_comment(hl: &mut Highlights, sema: &Semantics<RootDatabase>, n | |||
153 | if attributes.docs().map_or(true, |docs| !String::from(docs).contains(RUSTDOC_FENCE)) { | 153 | if attributes.docs().map_or(true, |docs| !String::from(docs).contains(RUSTDOC_FENCE)) { |
154 | return; | 154 | return; |
155 | } | 155 | } |
156 | let attrs_source_map = attributes.source_map(&owner); | ||
156 | 157 | ||
157 | let mut inj = Injector::default(); | 158 | let mut inj = Injector::default(); |
158 | inj.add_unmapped("fn doctest() {\n"); | 159 | inj.add_unmapped("fn doctest() {\n"); |
@@ -165,7 +166,7 @@ pub(super) fn doc_comment(hl: &mut Highlights, sema: &Semantics<RootDatabase>, n | |||
165 | let mut new_comments = Vec::new(); | 166 | let mut new_comments = Vec::new(); |
166 | let mut string; | 167 | let mut string; |
167 | for attr in attributes.by_key("doc").attrs() { | 168 | for attr in attributes.by_key("doc").attrs() { |
168 | let src = attr.to_src(&owner); | 169 | let src = attrs_source_map.source_of(&attr); |
169 | let (line, range, prefix) = match &src { | 170 | let (line, range, prefix) = match &src { |
170 | Either::Left(it) => { | 171 | Either::Left(it) => { |
171 | string = match find_doc_string_in_attr(attr, it) { | 172 | string = match find_doc_string_in_attr(attr, it) { |