Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4e1258c

Browse files
committed
IndexItem.name String -> Symbol
1 parent 60cc778 commit 4e1258c

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/librustdoc/formats/cache.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
242242
}
243243

244244
// Index this method for searching later on.
245-
if let Some(ref s) = item.name.or_else(|| {
245+
if let Some(s) = item.name.or_else(|| {
246246
if item.is_stripped() {
247247
None
248248
} else if let clean::ImportItem(ref i) = *item.kind &&
@@ -317,14 +317,15 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
317317
short_markdown_summary(x.as_str(), &item.link_names(self.cache))
318318
});
319319
let ty = item.type_();
320-
let name = s.to_string();
321-
if ty != ItemType::StructField || u16::from_str_radix(&name, 10).is_err() {
320+
if ty != ItemType::StructField
321+
|| u16::from_str_radix(s.as_str(), 10).is_err()
322+
{
322323
// In case this is a field from a tuple struct, we don't add it into
323324
// the search index because its name is something like "0", which is
324325
// not useful for rustdoc search.
325326
self.cache.search_index.push(IndexItem {
326327
ty,
327-
name,
328+
name: s,
328329
path: join_with_double_colon(path),
329330
desc,
330331
parent,

src/librustdoc/html/render/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
100100
#[derive(Debug)]
101101
pub(crate) struct IndexItem {
102102
pub(crate) ty: ItemType,
103-
pub(crate) name: String,
103+
pub(crate) name: Symbol,
104104
pub(crate) path: String,
105105
pub(crate) desc: String,
106106
pub(crate) parent: Option<DefId>,

src/librustdoc/html/render/search_index.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub(crate) fn build_index<'tcx>(
3535
.map_or_else(String::new, |s| short_markdown_summary(&s, &item.link_names(cache)));
3636
cache.search_index.push(IndexItem {
3737
ty: item.type_(),
38-
name: item.name.unwrap().to_string(),
38+
name: item.name.unwrap(),
3939
path: join_with_double_colon(&fqp[..fqp.len() - 1]),
4040
desc,
4141
parent: Some(parent),
@@ -58,8 +58,8 @@ pub(crate) fn build_index<'tcx>(
5858
// Sort search index items. This improves the compressibility of the search index.
5959
cache.search_index.sort_unstable_by(|k1, k2| {
6060
// `sort_unstable_by_key` produces lifetime errors
61-
let k1 = (&k1.path, &k1.name, &k1.ty, &k1.parent);
62-
let k2 = (&k2.path, &k2.name, &k2.ty, &k2.parent);
61+
let k1 = (&k1.path, k1.name.as_str(), &k1.ty, &k1.parent);
62+
let k2 = (&k2.path, k2.name.as_str(), &k2.ty, &k2.parent);
6363
std::cmp::Ord::cmp(&k1, &k2)
6464
});
6565

@@ -240,7 +240,7 @@ pub(crate) fn build_index<'tcx>(
240240
)?;
241241
crate_data.serialize_field(
242242
"n",
243-
&self.items.iter().map(|item| &item.name).collect::<Vec<_>>(),
243+
&self.items.iter().map(|item| item.name.as_str()).collect::<Vec<_>>(),
244244
)?;
245245
crate_data.serialize_field(
246246
"q",

0 commit comments

Comments
 (0)