about summary refs log tree commit diff
path: root/src/librustdoc/html/highlight.rs
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-10-01 22:15:00 +1000
committerGitHub <noreply@github.com>2025-10-01 22:15:00 +1000
commit62b72bd545d2caff23164732aa881ff6e169005d (patch)
tree268bd332222d97b32f4aa3b385fc3dd3ba2e8d34 /src/librustdoc/html/highlight.rs
parentca8ed7eb805f9be8767077510c9685cc692dd032 (diff)
parent2d03ab1486c11f2c5f8a19ae040b94edc090b279 (diff)
downloadrust-62b72bd545d2caff23164732aa881ff6e169005d.tar.gz
rust-62b72bd545d2caff23164732aa881ff6e169005d.zip
Rollup merge of #147189 - yotamofek:pr/rustdoc/highlight-optimizations-2, r=GuillaumeGomez
Replace `rustc_span::Span` with a stripped down version for librustdoc's highlighter

While profiling rustdoc's syntax highlighter, I noticed a lot of time being spent in the `Span` interner, due to the highlighter creating a lot of (new) spans.
Since the only data from the `Span` that we use is the `hi` and `lo` byte positions - I replaced the regular `Span` with a simple one with two fields, and in my benchmarks it seemed to make a big dent in the highlighter's perf, so thought I would see what the perf runner says.
Diffstat (limited to 'src/librustdoc/html/highlight.rs')
-rw-r--r--src/librustdoc/html/highlight.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs
index fad15573cde..1dcb4dcc3ff 100644
--- a/src/librustdoc/html/highlight.rs
+++ b/src/librustdoc/html/highlight.rs
@@ -12,15 +12,16 @@ use std::iter;
 
 use rustc_data_structures::fx::FxIndexMap;
 use rustc_lexer::{Cursor, FrontmatterAllowed, LiteralKind, TokenKind};
+use rustc_span::BytePos;
 use rustc_span::edition::Edition;
 use rustc_span::symbol::Symbol;
-use rustc_span::{BytePos, DUMMY_SP, Span};
 
 use super::format;
 use crate::clean::PrimitiveType;
 use crate::display::Joined as _;
 use crate::html::escape::EscapeBodyText;
 use crate::html::macro_expansion::ExpandedCode;
+use crate::html::render::span_map::{DUMMY_SP, Span};
 use crate::html::render::{Context, LinkFromSrc};
 
 /// This type is needed in case we want to render links on items to allow to go to their definition.