mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
Use SmallVec
to slightly shrink ModPath
size
This commit is contained in:
parent
00194ade76
commit
d2fd137252
3 changed files with 6 additions and 3 deletions
|
@ -12,12 +12,13 @@ use crate::{
|
|||
};
|
||||
use base_db::CrateId;
|
||||
use either::Either;
|
||||
use smallvec::SmallVec;
|
||||
use syntax::{ast, AstNode};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct ModPath {
|
||||
pub kind: PathKind,
|
||||
segments: Vec<Name>,
|
||||
segments: SmallVec<[Name; 1]>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
@ -41,13 +42,13 @@ impl ModPath {
|
|||
}
|
||||
|
||||
pub fn from_segments(kind: PathKind, segments: impl IntoIterator<Item = Name>) -> ModPath {
|
||||
let segments = segments.into_iter().collect::<Vec<_>>();
|
||||
let segments = segments.into_iter().collect();
|
||||
ModPath { kind, segments }
|
||||
}
|
||||
|
||||
/// Creates a `ModPath` from a `PathKind`, with no extra path segments.
|
||||
pub const fn from_kind(kind: PathKind) -> ModPath {
|
||||
ModPath { kind, segments: Vec::new() }
|
||||
ModPath { kind, segments: SmallVec::new_const() }
|
||||
}
|
||||
|
||||
pub fn segments(&self) -> &[Name] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue