1
Fork 0

rustdoc: Use ThinVec in a few places

Almost every crate has no primitives and no keywords defined in it, so
using `ThinVec` should make some types smaller.
This commit is contained in:
Camelid 2021-04-02 18:32:06 -07:00
parent 5c897d430d
commit 3ea8ebcc2d

View file

@ -9,11 +9,13 @@ use std::sync::Arc;
use std::{slice, vec}; use std::{slice, vec};
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use rustc_ast::attr; use rustc_ast::attr;
use rustc_ast::util::comments::beautify_doc_string; use rustc_ast::util::comments::beautify_doc_string;
use rustc_ast::{self as ast, AttrStyle}; use rustc_ast::{self as ast, AttrStyle};
use rustc_attr::{ConstStability, Deprecation, Stability, StabilityLevel}; use rustc_attr::{ConstStability, Deprecation, Stability, StabilityLevel};
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::thin_vec::ThinVec;
use rustc_feature::UnstableFeatures; use rustc_feature::UnstableFeatures;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{CtorKind, Res}; use rustc_hir::def::{CtorKind, Res};
@ -54,7 +56,7 @@ crate struct Crate {
crate src: FileName, crate src: FileName,
crate module: Item, crate module: Item,
crate externs: Vec<(CrateNum, ExternalCrate)>, crate externs: Vec<(CrateNum, ExternalCrate)>,
crate primitives: Vec<(DefId, PrimitiveType)>, crate primitives: ThinVec<(DefId, PrimitiveType)>,
// These are later on moved into `CACHEKEY`, leaving the map empty. // These are later on moved into `CACHEKEY`, leaving the map empty.
// Only here so that they can be filtered through the rustdoc passes. // Only here so that they can be filtered through the rustdoc passes.
crate external_traits: Rc<RefCell<FxHashMap<DefId, TraitWithExtraInfo>>>, crate external_traits: Rc<RefCell<FxHashMap<DefId, TraitWithExtraInfo>>>,
@ -73,8 +75,8 @@ crate struct ExternalCrate {
crate name: Symbol, crate name: Symbol,
crate src: FileName, crate src: FileName,
crate attrs: Attributes, crate attrs: Attributes,
crate primitives: Vec<(DefId, PrimitiveType)>, crate primitives: ThinVec<(DefId, PrimitiveType)>,
crate keywords: Vec<(DefId, Symbol)>, crate keywords: ThinVec<(DefId, Symbol)>,
} }
/// Anything with a source location and set of attributes and, optionally, a /// Anything with a source location and set of attributes and, optionally, a