Skip to content

Commit

Permalink
Clone ID map instead of keeping them split
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 23, 2024
1 parent c4c6cb2 commit 3c3218d
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,16 +1950,7 @@ impl IdMap {

pub(crate) fn derive<S: AsRef<str> + ToString>(&mut self, candidate: S) -> String {
let id = match self.map.get_mut(candidate.as_ref()) {
None => {
let candidate = candidate.to_string();
if self.defined_ids.contains(candidate.as_str()) {
let id = format!("{}-{}", candidate, 1);
self.map.insert(candidate.into(), 2);
id
} else {
candidate.to_string()
}
}
None => candidate.to_string(),
Some(a) => {
let id = format!("{}-{}", candidate.as_ref(), *a);
*a += 1;
Expand All @@ -1981,7 +1972,7 @@ impl IdMap {
}

pub(crate) fn clear(&mut self) {
self.map.clear();
self.map = self.defined_ids.clone();
self.existing_footnotes = 0;
}
}

0 comments on commit 3c3218d

Please sign in to comment.