Rollup merge of #122530 - klensy:as_str, r=fee1-dead

less symbol interner locks

This reduces instructions under 1% (in rustdoc run), but essentially free.
This commit is contained in:
Guillaume Gomez 2024-03-15 17:24:10 +01:00 committed by GitHub
commit 6ec4092eaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View File

@ -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);

View File

@ -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}\">");