Skip to content

Commit 3c3218d

Browse files
Clone ID map instead of keeping them split
1 parent c4c6cb2 commit 3c3218d

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/librustdoc/html/markdown.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -1950,16 +1950,7 @@ impl IdMap {
19501950

19511951
pub(crate) fn derive<S: AsRef<str> + ToString>(&mut self, candidate: S) -> String {
19521952
let id = match self.map.get_mut(candidate.as_ref()) {
1953-
None => {
1954-
let candidate = candidate.to_string();
1955-
if self.defined_ids.contains(candidate.as_str()) {
1956-
let id = format!("{}-{}", candidate, 1);
1957-
self.map.insert(candidate.into(), 2);
1958-
id
1959-
} else {
1960-
candidate.to_string()
1961-
}
1962-
}
1953+
None => candidate.to_string(),
19631954
Some(a) => {
19641955
let id = format!("{}-{}", candidate.as_ref(), *a);
19651956
*a += 1;
@@ -1981,7 +1972,7 @@ impl IdMap {
19811972
}
19821973

19831974
pub(crate) fn clear(&mut self) {
1984-
self.map.clear();
1975+
self.map = self.defined_ids.clone();
19851976
self.existing_footnotes = 0;
19861977
}
19871978
}

0 commit comments

Comments
 (0)