diff options
| author | Michael Howell <michael@notriddle.com> | 2025-09-25 15:16:16 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2025-09-25 15:16:16 -0700 |
| commit | 9dce3e8556022599c1323cdad6a0d87d6991c8b5 (patch) | |
| tree | 2e43706e2c03fef70b967b945c2f8919d622ffd4 /src/librustdoc/html | |
| parent | b9037f97e38acc698af1260cad5d31ca07ac616a (diff) | |
| download | rust-9dce3e8556022599c1323cdad6a0d87d6991c8b5.tar.gz rust-9dce3e8556022599c1323cdad6a0d87d6991c8b5.zip | |
rustdoc-search: add descriptive comment to space-saving hack
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/render/search_index.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 74cf2b18123..7b21c68d2e9 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -241,6 +241,9 @@ impl SerializedSearchIndex { self.alias_pointers.push(alias_pointer); index } + /// Add potential search result to the database and return the row ID. + /// + /// The returned ID can be used to attach more data to the search result. fn add_entry(&mut self, name: Symbol, entry_data: EntryData, desc: String) -> usize { let fqp = if let Some(module_path_index) = entry_data.module_path { let mut fqp = self.path_data[module_path_index].as_ref().unwrap().module_path.clone(); @@ -250,6 +253,11 @@ impl SerializedSearchIndex { } else { vec![name] }; + // If a path with the same name already exists, but no entry does, + // we can fill in the entry without having to allocate a new row ID. + // + // Because paths and entries both share the same index, using the same + // ID saves space by making the tree smaller. if let Some(&other_path) = self.crate_paths_index.get(&(entry_data.ty, fqp)) && self.entry_data[other_path].is_none() && self.descs[other_path].is_empty() |
