Skip to content

Commit

Permalink
Rollup merge of #122530 - klensy:as_str, r=fee1-dead
Browse files Browse the repository at this point in the history
less symbol interner locks

This reduces instructions under 1% (in rustdoc run), but essentially free.
  • Loading branch information
GuillaumeGomez authored Mar 15, 2024
2 parents 3d4464d + 7ea4f35 commit 6ec4092
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions compiler/rustc_resolve/src/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ pub fn unindent_doc_fragments(docs: &mut [DocFragment]) {
///
/// Note: remove the trailing newline where appropriate
pub fn add_doc_fragment(out: &mut String, frag: &DocFragment) {
let s = frag.doc.as_str();
let mut iter = s.lines();
if s.is_empty() {
if frag.doc == kw::Empty {
out.push('\n');
return;
}
let s = frag.doc.as_str();
let mut iter = s.lines();

while let Some(line) = iter.next() {
if line.chars().any(|c| !c.is_whitespace()) {
assert!(line.len() >= frag.indent);
Expand Down
7 changes: 4 additions & 3 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1698,9 +1698,10 @@ fn render_impl(
let id = cx.derive_id(format!("{item_type}.{name}"));
let source_id = trait_
.and_then(|trait_| {
trait_.items.iter().find(|item| {
item.name.map(|n| n.as_str().eq(name.as_str())).unwrap_or(false)
})
trait_
.items
.iter()
.find(|item| item.name.map(|n| n == *name).unwrap_or(false))
})
.map(|item| format!("{}.{name}", item.type_()));
write!(w, "<section id=\"{id}\" class=\"{item_type}{in_trait_class}\">");
Expand Down

0 comments on commit 6ec4092

Please sign in to comment.