Reduce allocations.

This commit is contained in:
Camille GILLOT
2019-12-30 23:09:35 +01:00
parent 8f05d12c67
commit be6cb63fcc
3 changed files with 8 additions and 9 deletions
+6 -8
View File
@@ -73,12 +73,10 @@
use rustc_error_codes::*;
macro_rules! arena_vec {
() => (
&[]
);
($this:expr; $($x:expr),*) => (
$this.arena.alloc_from_iter(vec![$($x),*])
);
($this:expr; $($x:expr),*) => ({
let a = [$($x),*];
$this.arena.alloc_from_iter(std::array::IntoIter::new(a))
});
}
mod expr;
@@ -2018,7 +2016,7 @@ fn lower_parenthesized_parameter_data(
FunctionRetTy::Ty(ty) => this.lower_ty(&ty, ImplTraitContext::disallowed()),
FunctionRetTy::Default(_) => this.arena.alloc(this.ty_tup(span, &[])),
};
let args = vec![GenericArg::Type(this.ty_tup(span, inputs))];
let args = smallvec![GenericArg::Type(this.ty_tup(span, inputs))];
let binding = hir::TypeBinding {
hir_id: this.next_id(),
ident: Ident::with_dummy_span(FN_OUTPUT_NAME),
@@ -3300,7 +3298,7 @@ fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body<'hir>>) -> Vec<hir::BodyId>
/// Helper struct for delayed construction of GenericArgs.
struct GenericArgsCtor<'hir> {
args: Vec<hir::GenericArg<'hir>>,
args: SmallVec<[hir::GenericArg<'hir>; 1]>,
bindings: &'hir [hir::TypeBinding<'hir>],
parenthesized: bool,
}
+1 -1
View File
@@ -1424,7 +1424,7 @@ fn lower_where_predicate(&mut self, pred: &WherePredicate) -> hir::WherePredicat
/// Helper struct for delayed construction of Generics.
pub(super) struct GenericsCtor<'hir> {
pub(super) params: Vec<hir::GenericParam<'hir>>,
pub(super) params: SmallVec<[hir::GenericParam<'hir>; 1]>,
where_clause: hir::WhereClause<'hir>,
span: Span,
}
+1
View File
@@ -28,6 +28,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(arbitrary_self_types)]
#![feature(array_value_iter)]
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]