diff options
| author | bors <bors@rust-lang.org> | 2018-09-26 10:04:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-26 10:04:42 +0000 |
| commit | c3a1a0d3400bbbcac194efb6ef2b14eef9be5149 (patch) | |
| tree | 0a75f20d6c5a9def5008fd24194e83946f9ac9db /src/libsyntax/ext/base.rs | |
| parent | a2b27c19dad8b90063b56eff7b6433ba3f390d96 (diff) | |
| parent | 130a32fa7259d348dc3a684b38e688da398c30bb (diff) | |
Auto merge of #53824 - ljedrz:begone_onevector, r=michaelwoerister
Remove OneVector, increase related SmallVec capacities Removes the `OneVector` type alias (equivalent to `SmallVec<[T; 1]>`); it is used in scenarios where the capacity of 1 is often exceeded, which might be nullifying the performance wins (due to spilling to the heap) expected when using `SmallVec` instead of `Vec`. The numbers I used in this PR are very rough estimates - it would probably be a good idea to adjust some/all of them, which is what this proposal is all about. It might be a good idea to additionally create some local type aliases for the `SmallVec`s in the `Folder` trait, as they are repeated in quite a few spots; I'd be happy to apply this sort of adjustments.
Diffstat (limited to 'src/libsyntax/ext/base.rs')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index e42624bf41f..5bf1a7dd663 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -22,7 +22,7 @@ use fold::{self, Folder}; use parse::{self, parser, DirectoryOwnership}; use parse::token; use ptr::P; -use OneVector; +use smallvec::SmallVec; use symbol::{keywords, Ident, Symbol}; use ThinVec; @@ -332,22 +332,22 @@ pub trait MacResult { None } /// Create zero or more items. - fn make_items(self: Box<Self>) -> Option<OneVector<P<ast::Item>>> { + fn make_items(self: Box<Self>) -> Option<SmallVec<[P<ast::Item>; 1]>> { None } /// Create zero or more impl items. - fn make_impl_items(self: Box<Self>) -> Option<OneVector<ast::ImplItem>> { + fn make_impl_items(self: Box<Self>) -> Option<SmallVec<[ast::ImplItem; 1]>> { None } /// Create zero or more trait items. - fn make_trait_items(self: Box<Self>) -> Option<OneVector<ast::TraitItem>> { + fn make_trait_items(self: Box<Self>) -> Option<SmallVec<[ast::TraitItem; 1]>> { None } /// Create zero or more items in an `extern {}` block - fn make_foreign_items(self: Box<Self>) -> Option<OneVector<ast::ForeignItem>> { None } + fn make_foreign_items(self: Box<Self>) -> Option<SmallVec<[ast::ForeignItem; 1]>> { None } /// Create a pattern. fn make_pat(self: Box<Self>) -> Option<P<ast::Pat>> { @@ -358,7 +358,7 @@ pub trait MacResult { /// /// By default this attempts to create an expression statement, /// returning None if that fails. - fn make_stmts(self: Box<Self>) -> Option<OneVector<ast::Stmt>> { + fn make_stmts(self: Box<Self>) -> Option<SmallVec<[ast::Stmt; 1]>> { make_stmts_default!(self) } @@ -394,11 +394,11 @@ macro_rules! make_MacEager { make_MacEager! { expr: P<ast::Expr>, pat: P<ast::Pat>, - items: OneVector<P<ast::Item>>, - impl_items: OneVector<ast::ImplItem>, - trait_items: OneVector<ast::TraitItem>, - foreign_items: OneVector<ast::ForeignItem>, - stmts: OneVector<ast::Stmt>, + items: SmallVec<[P<ast::Item>; 1]>, + impl_items: SmallVec<[ast::ImplItem; 1]>, + trait_items: SmallVec<[ast::TraitItem; 1]>, + foreign_items: SmallVec<[ast::ForeignItem; 1]>, + stmts: SmallVec<[ast::Stmt; 1]>, ty: P<ast::Ty>, } @@ -407,23 +407,23 @@ impl MacResult for MacEager { self.expr } - fn make_items(self: Box<Self>) -> Option<OneVector<P<ast::Item>>> { + fn make_items(self: Box<Self>) -> Option<SmallVec<[P<ast::Item>; 1]>> { self.items } - fn make_impl_items(self: Box<Self>) -> Option<OneVector<ast::ImplItem>> { + fn make_impl_items(self: Box<Self>) -> Option<SmallVec<[ast::ImplItem; 1]>> { self.impl_items } - fn make_trait_items(self: Box<Self>) -> Option<OneVector<ast::TraitItem>> { + fn make_trait_items(self: Box<Self>) -> Option<SmallVec<[ast::TraitItem; 1]>> { self.trait_items } - fn make_foreign_items(self: Box<Self>) -> Option<OneVector<ast::ForeignItem>> { + fn make_foreign_items(self: Box<Self>) -> Option<SmallVec<[ast::ForeignItem; 1]>> { self.foreign_items } - fn make_stmts(self: Box<Self>) -> Option<OneVector<ast::Stmt>> { + fn make_stmts(self: Box<Self>) -> Option<SmallVec<[ast::Stmt; 1]>> { match self.stmts.as_ref().map_or(0, |s| s.len()) { 0 => make_stmts_default!(self), _ => self.stmts, @@ -514,40 +514,40 @@ impl MacResult for DummyResult { Some(P(DummyResult::raw_pat(self.span))) } - fn make_items(self: Box<DummyResult>) -> Option<OneVector<P<ast::Item>>> { + fn make_items(self: Box<DummyResult>) -> Option<SmallVec<[P<ast::Item>; 1]>> { // this code needs a comment... why not always just return the Some() ? if self.expr_only { None } else { - Some(OneVector::new()) + Some(SmallVec::new()) } } - fn make_impl_items(self: Box<DummyResult>) -> Option<OneVector<ast::ImplItem>> { + fn make_impl_items(self: Box<DummyResult>) -> Option<SmallVec<[ast::ImplItem; 1]>> { if self.expr_only { None } else { - Some(OneVector::new()) + Some(SmallVec::new()) } } - fn make_trait_items(self: Box<DummyResult>) -> Option<OneVector<ast::TraitItem>> { + fn make_trait_items(self: Box<DummyResult>) -> Option<SmallVec<[ast::TraitItem; 1]>> { if self.expr_only { None } else { - Some(OneVector::new()) + Some(SmallVec::new()) } } - fn make_foreign_items(self: Box<Self>) -> Option<OneVector<ast::ForeignItem>> { + fn make_foreign_items(self: Box<Self>) -> Option<SmallVec<[ast::ForeignItem; 1]>> { if self.expr_only { None } else { - Some(OneVector::new()) + Some(SmallVec::new()) } } - fn make_stmts(self: Box<DummyResult>) -> Option<OneVector<ast::Stmt>> { + fn make_stmts(self: Box<DummyResult>) -> Option<SmallVec<[ast::Stmt; 1]>> { Some(smallvec