mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Reduce allocations.
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user