Skip to content

Commit b0dd64f

Browse files
notriddlecuviper
authored andcommitted
rustdoc-search: add descriptive comment to space-saving hack
(cherry picked from commit 9dce3e8)
1 parent 8127760 commit b0dd64f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/librustdoc/html/render/search_index.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ impl SerializedSearchIndex {
239239
self.alias_pointers.push(alias_pointer);
240240
index
241241
}
242+
/// Add potential search result to the database and return the row ID.
243+
///
244+
/// The returned ID can be used to attach more data to the search result.
242245
fn add_entry(&mut self, name: Symbol, entry_data: EntryData, desc: String) -> usize {
243246
let fqp = if let Some(module_path_index) = entry_data.module_path {
244247
let mut fqp = self.path_data[module_path_index].as_ref().unwrap().module_path.clone();
@@ -248,6 +251,11 @@ impl SerializedSearchIndex {
248251
} else {
249252
vec![name]
250253
};
254+
// If a path with the same name already exists, but no entry does,
255+
// we can fill in the entry without having to allocate a new row ID.
256+
//
257+
// Because paths and entries both share the same index, using the same
258+
// ID saves space by making the tree smaller.
251259
if let Some(&other_path) = self.crate_paths_index.get(&(entry_data.ty, fqp))
252260
&& self.entry_data[other_path].is_none()
253261
&& self.descs[other_path].is_empty()

0 commit comments

Comments
 (0)