Builder::new_lifetime_param (LifetimeParam ¶m)
{
Lifetime l = new_lifetime (param.get_lifetime ());
+
std::vector<Lifetime> lifetime_bounds;
+ lifetime_bounds.reserve (param.get_lifetime_bounds ().size ());
+
for (auto b : param.get_lifetime_bounds ())
- {
- Lifetime bl = new_lifetime (b);
- lifetime_bounds.push_back (bl);
- }
+ lifetime_bounds.emplace_back (new_lifetime (b));
auto p = new LifetimeParam (l, std::move (lifetime_bounds),
param.get_outer_attrs (), param.get_locus ());
for (const auto &lifetime : tb.get_for_lifetimes ())
{
std::vector<Lifetime> lifetime_bounds;
+ lifetime_bounds.reserve (
+ lifetime.get_lifetime_bounds ().size ());
+
for (const auto &b : lifetime.get_lifetime_bounds ())
- {
- Lifetime bl = new_lifetime (b);
- lifetime_bounds.push_back (std::move (bl));
- }
+ lifetime_bounds.emplace_back (new_lifetime (b));
Lifetime nl = new_lifetime (lifetime.get_lifetime ());
LifetimeParam p (std::move (nl), std::move (lifetime_bounds),
{
const TypePathSegment &segment
= (const TypePathSegment &) (*seg.get ());
- TypePathSegment *s = new TypePathSegment (
+
+ segments.emplace_back (new TypePathSegment (
segment.get_ident_segment (),
segment.get_separating_scope_resolution (),
- segment.get_locus ());
- std::unique_ptr<TypePathSegment> sg (s);
- segments.push_back (std::move (sg));
+ segment.get_locus ()));
}
break;
GenericArgs args
= new_generic_args (generic.get_generic_args ());
- TypePathSegmentGeneric *s = new TypePathSegmentGeneric (
+
+ segments.emplace_back (new TypePathSegmentGeneric (
generic.get_ident_segment (), false, std::move (args),
- generic.get_locus ());
- std::unique_ptr<TypePathSegment> sg (s);
- segments.push_back (std::move (sg));
+ generic.get_locus ()));
}
break;
TypePath p (std::move (segments), path.get_locus (),
path.has_opening_scope_resolution_op ());
- TraitBound *b = new TraitBound (std::move (p), tb.get_locus (),
- tb.is_in_parens (),
- tb.has_opening_question_mark (),
- std::move (for_lifetimes));
- std::unique_ptr<TypeParamBound> bound (b);
- type_param_bounds.push_back (std::move (bound));
+ type_param_bounds.emplace_back (new TraitBound (
+ std::move (p), tb.get_locus (), tb.is_in_parens (),
+ tb.has_opening_question_mark (), std::move (for_lifetimes)));
}
break;
{
const Lifetime &l = (const Lifetime &) *b.get ();
- auto bl = new Lifetime (l.get_lifetime_type (),
- l.get_lifetime_name (), l.get_locus ());
- std::unique_ptr<TypeParamBound> bound (bl);
- type_param_bounds.push_back (std::move (bound));
+ type_param_bounds.emplace_back (
+ new Lifetime (l.get_lifetime_type (), l.get_lifetime_name (),
+ l.get_locus ()));
}
break;
}
location_t locus = args.get_locus ();
for (const auto &lifetime : args.get_lifetime_args ())
- {
- Lifetime l = new_lifetime (lifetime);
- lifetime_args.push_back (std::move (l));
- }
+ lifetime_args.push_back (new_lifetime (lifetime));
for (auto &binding : args.get_binding_args ())
{
Type &t = *binding.get_type_ptr ().get ();
std::unique_ptr<Type> ty = t.reconstruct ();
- GenericArgsBinding b (binding.get_identifier (), std::move (ty),
- binding.get_locus ());
- binding_args.push_back (std::move (b));
+ binding_args.emplace_back (binding.get_identifier (), std::move (ty),
+ binding.get_locus ());
}
for (auto &arg : args.get_generic_args ())
void
TokenCollector::newline ()
{
- tokens.push_back ({CollectItem::Kind::Newline});
+ tokens.emplace_back (CollectItem::Kind::Newline);
}
void
TokenCollector::indentation ()
{
- tokens.push_back ({indent_level});
+ tokens.emplace_back (indent_level);
}
void
void
TokenCollector::comment (std::string comment)
{
- tokens.push_back ({comment});
+ tokens.emplace_back (comment);
}
void
// Convert to TypePath by creating path segments
std::vector<std::unique_ptr<TypePathSegment>> segments;
- segments.push_back (std::unique_ptr<TypePathSegment> (new TypePathSegment (
- PathIdentSegment (ident.as_string (), type.get_locus ()), false,
- type.get_locus ())));
+ segments.emplace_back (
+ new TypePathSegment (PathIdentSegment (ident.as_string (),
+ type.get_locus ()),
+ false, type.get_locus ()));
// Create TypePath from segments
auto type_path
// Convert bounds from impl trait to generic parameter bounds
std::vector<std::unique_ptr<TypeParamBound>> bounds;
+ bounds.reserve (type.get_type_param_bounds ().size ());
+
for (auto &bound : type.get_type_param_bounds ())
bounds.push_back (bound->clone_type_param_bound ());
// Convert to TypePath by creating path segments
std::vector<std::unique_ptr<TypePathSegment>> segments;
- segments.push_back (std::unique_ptr<TypePathSegment> (new TypePathSegment (
- PathIdentSegment (ident.as_string (), type.get_locus ()), false,
- type.get_locus ())));
+ segments.emplace_back (
+ new TypePathSegment (PathIdentSegment (ident.as_string (),
+ type.get_locus ()),
+ false, type.get_locus ()));
// Create TypePath from segments
auto type_path
std::vector<std::unique_ptr<TypeParamBound>>
type_param_bounds;
+ type_param_bounds.reserve (
+ tp.get_type_param_bounds ().size ());
+
for (auto &b : tp.get_type_param_bounds ())
type_param_bounds.push_back (std::move (b));
tp.get_type_param_bounds ().clear ();
std::vector<SimplePathSegment> simple_segs = {simple_seg};
auto simple_path = SimplePath (simple_segs, false, ident.get_locus ());
std::vector<std::unique_ptr<TypePathSegment>> segments;
- segments.push_back (std::unique_ptr<TypePathSegment> (new TypePathSegment (
- PathIdentSegment (ident.as_string (), ident.get_locus ()), false,
- ident.get_locus ())));
+ segments.emplace_back (
+ new TypePathSegment (PathIdentSegment (ident.as_string (),
+ ident.get_locus ()),
+ false, ident.get_locus ()));
auto type_path = new TypePath (std::move (segments), ident.get_locus ());
return std::unique_ptr<Type> (type_path);
}
struct TupleClobber
{
+ TupleClobber (std::string symbol, location_t loc) : symbol (symbol), loc (loc)
+ {}
// as gccrs still doesn't contain a symbol class I have put them as strings
std::string symbol;
location_t loc;
// create segment and add to vector
std::string segment_str = segment.as_string ();
- simple_segments.push_back (
- SimplePathSegment (std::move (segment_str), segment.get_locus ()));
+ simple_segments.emplace_back (std::move (segment_str),
+ segment.get_locus ());
}
// kind of a HACK to get locus depending on opening scope resolution
// create segment and add to vector
std::string segment_str = segment->as_string ();
- simple_segments.push_back (
- SimplePathSegment (std::move (segment_str), segment->get_locus ()));
+ simple_segments.emplace_back (std::move (segment_str),
+ segment->get_locus ());
}
return SimplePath (std::move (simple_segments), has_opening_scope_resolution,
generic_args.clear ();
generic_args.reserve (other.generic_args.size ());
for (const auto &arg : other.generic_args)
- {
- generic_args.push_back (GenericArg (arg));
- }
+ generic_args.emplace_back (arg);
}
~GenericArgs () = default;
generic_args.clear ();
generic_args.reserve (other.generic_args.size ());
for (const auto &arg : other.generic_args)
- {
- generic_args.push_back (GenericArg (arg));
- }
+ generic_args.emplace_back (arg);
return *this;
}
struct fncontext
{
+ fncontext (tree fndecl, ::Bvariable *ret_addr, TyTy::BaseType *retty)
+ : fndecl (fndecl), ret_addr (ret_addr), retty (retty)
+ {}
+
tree fndecl;
::Bvariable *ret_addr;
TyTy::BaseType *retty;
if (it == mono_fns.end ())
mono_fns[dId] = {};
- mono_fns[dId].push_back ({ref, fn});
+ mono_fns[dId].emplace_back (ref, fn);
}
void insert_closure_decl (const TyTy::ClosureType *ref, tree fn)
if (it == mono_closure_fns.end ())
mono_closure_fns[dId] = {};
- mono_closure_fns[dId].push_back ({ref, fn});
+ mono_closure_fns[dId].emplace_back (ref, fn);
}
tree lookup_closure_decl (const TyTy::ClosureType *ref)
void push_fn (tree fn, ::Bvariable *ret_addr, TyTy::BaseType *retty)
{
- fn_stack.push_back (fncontext{fn, ret_addr, retty});
+ fn_stack.emplace_back (fn, ret_addr, retty);
}
void pop_fn () { fn_stack.pop_back (); }
// this should be based on the closure move-ability
tree decl_type = TyTyResolveCompile::compile (ctx, lookup);
tree capture_type = build_reference_type (decl_type);
- fields.push_back (Backend::typed_identifier (mappings_name, capture_type,
- type.get_ident ().locus));
+ fields.emplace_back (mappings_name, capture_type,
+ type.get_ident ().locus);
}
tree type_record = Backend::struct_type (fields);
auto ret = TyTyResolveCompile::compile (ctx, hir_type, trait_object_mode);
location_t return_type_locus
= ctx->get_mappings ().lookup_location (hir_type->get_ref ());
- results.push_back (
- Backend::typed_identifier ("_", ret, return_type_locus));
+ results.emplace_back ("_", ret, return_type_locus);
}
for (auto ¶m_pair : type.get_params ())
auto compiled_param_type
= TyTyResolveCompile::compile (ctx, param_tyty, trait_object_mode);
- auto compiled_param = Backend::typed_identifier (
- param_pair.get_pattern ().as_string (), compiled_param_type,
- ctx->get_mappings ().lookup_location (param_tyty->get_ref ()));
-
- parameters.push_back (compiled_param);
+ parameters.emplace_back (param_pair.get_pattern ().as_string (),
+ compiled_param_type,
+ ctx->get_mappings ().lookup_location (
+ param_tyty->get_ref ()));
}
if (!type.is_variadic ())
tree compiled_field_ty
= TyTyResolveCompile::compile (ctx, field->get_field_type ());
- Backend::typed_identifier f (field->get_name (), compiled_field_ty,
- ctx->get_mappings ().lookup_location (
- type.get_ty_ref ()));
- fields.push_back (std::move (f));
+ fields.emplace_back (field->get_name (), compiled_field_ty,
+ ctx->get_mappings ().lookup_location (
+ type.get_ty_ref ()));
}
type_record = type.is_union () ? Backend::union_type (fields, false)
== TyTy::VariantDef::VariantType::TUPLE)
field_name = "__" + field->get_name ();
- Backend::typed_identifier f (
- field_name, compiled_field_ty,
- ctx->get_mappings ().lookup_location (type.get_ty_ref ()));
- fields.push_back (std::move (f));
+ fields.emplace_back (field_name, compiled_field_ty,
+ ctx->get_mappings ().lookup_location (
+ type.get_ty_ref ()));
}
tree variant_record = Backend::struct_type (fields);
TyTy::VariantDef *variant = type.get_variants ().at (i++);
std::string implicit_variant_name = variant->get_identifier ();
- Backend::typed_identifier f (implicit_variant_name, variant_record,
- ctx->get_mappings ().lookup_location (
- type.get_ty_ref ()));
- enum_fields.push_back (std::move (f));
+ enum_fields.emplace_back (implicit_variant_name, variant_record,
+ ctx->get_mappings ().lookup_location (
+ type.get_ty_ref ()));
}
//
// this, rather than simply emitting the integer, is that this
// approach makes it simpler to use a C-only debugger, or
// GDB's C mode, when debugging Rust.
- Backend::typed_identifier f ("__" + std::to_string (i), compiled_field_ty,
- ctx->get_mappings ().lookup_location (
- type.get_ty_ref ()));
- fields.push_back (std::move (f));
+ fields.emplace_back ("__" + std::to_string (i), compiled_field_ty,
+ ctx->get_mappings ().lookup_location (
+ type.get_ty_ref ()));
}
tree struct_type_record = Backend::struct_type (fields);
tree uint = Backend::integer_type (true, Backend::get_pointer_size ());
tree uintptr_ty = build_pointer_type (uint);
- Backend::typed_identifier f ("pointer", uintptr_ty,
- ctx->get_mappings ().lookup_location (
- type.get_ty_ref ()));
- fields.push_back (std::move (f));
+ fields.emplace_back ("pointer", uintptr_ty,
+ ctx->get_mappings ().lookup_location (
+ type.get_ty_ref ()));
tree vtable_size = build_int_cst (size_type_node, items.size ());
tree vtable_type = Backend::array_type (uintptr_ty, vtable_size);
- Backend::typed_identifier vtf ("vtable", vtable_type,
- ctx->get_mappings ().lookup_location (
- type.get_ty_ref ()));
- fields.push_back (std::move (vtf));
+ fields.emplace_back ("vtable", vtable_type,
+ ctx->get_mappings ().lookup_location (
+ type.get_ty_ref ()));
tree record = Backend::struct_type (fields);
RS_DST_FLAG (record) = 1;
if (ctor.is_covered_by (hd.ctor ()))
{
pats.pop_head_constructor (ctor, subfields_place_info.size ());
- new_rows.push_back (MatrixRow (pats, row.is_under_guard ()));
+ new_rows.emplace_back (pats, row.is_under_guard ());
}
}
}
}
- stack.push_back (WitnessPat (ctor, subfield, ty));
+ stack.emplace_back (ctor, subfield, ty);
}
}
MatchArm lowered = lower_arm (ctx, arm, scrutinee_ty);
PatOrWild pat = PatOrWild::make_pattern (lowered.get_pat ());
pats.push (pat);
- rows.push_back (MatrixRow (pats, lowered.has_guard ()));
+ rows.emplace_back (pats, lowered.has_guard ());
}
std::vector<PlaceInfo> place_infos = {{PlaceInfo (scrutinee_ty)}};
new BlockExpr ({}, std::move (clone_expr), {}, {}, tl::nullopt, loc, loc));
auto big_self_type = builder.single_type_path ("Self");
- std::unique_ptr<SelfParam> self (new SelfParam (tl::nullopt,
- /* is_mut */ false, loc));
-
std::vector<std::unique_ptr<Param>> params;
- params.push_back (std::move (self));
+
+ params.emplace_back (new SelfParam (tl::nullopt,
+ /* is_mut */ false, loc));
return std::unique_ptr<AssociatedItem> (
new Function ({"clone"}, builder.fn_qualifiers (), /* generics */ {},
if (token->get_id () == STRING_LITERAL)
{
// TODO: Caring for span in here.
- new_abis.push_back ({token->as_string (), token->get_locus ()});
+ new_abis.emplace_back (token->as_string (), token->get_locus ());
}
else
{
auto result = parser.parse_item (false);
if (result == nullptr)
break;
- nodes.push_back ({std::move (result)});
+ nodes.emplace_back (std::move (result));
}
break;
case ContextType::STMT:
auto result = parser.parse_stmt ();
if (result == nullptr)
break;
- nodes.push_back ({std::move (result)});
+ nodes.emplace_back (std::move (result));
}
break;
case ContextType::TRAIT:
std::vector<std::unique_ptr<AST::GenericParam>> ¶ms)
{
std::vector<std::unique_ptr<HIR::GenericParam>> lowered;
+ lowered.reserve (params.size ());
+
for (auto &ast_param : params)
- {
- auto hir_param = ASTLowerGenericParam::translate (*ast_param);
- lowered.push_back (std::unique_ptr<HIR::GenericParam> (hir_param));
- }
+ lowered.emplace_back (ASTLowerGenericParam::translate (*ast_param));
return lowered;
}
ASTLoweringBase::lower_generic_args (AST::GenericArgs &args)
{
std::vector<HIR::GenericArgsBinding> binding_args;
+ binding_args.reserve (args.get_binding_args ().size ());
+
for (auto &binding : args.get_binding_args ())
- {
- HIR::GenericArgsBinding b = lower_binding (binding);
- binding_args.push_back (std::move (b));
- }
+ binding_args.emplace_back (lower_binding (binding));
std::vector<HIR::Lifetime> lifetime_args;
+ lifetime_args.reserve (args.get_lifetime_args ().size ());
+
for (auto &lifetime : args.get_lifetime_args ())
- {
- HIR::Lifetime l = lower_lifetime (lifetime);
- lifetime_args.push_back (std::move (l));
- }
+ lifetime_args.emplace_back (lower_lifetime (lifetime));
std::vector<std::unique_ptr<HIR::Type>> type_args;
std::vector<HIR::ConstGenericArg> const_args;
{
case AST::GenericArg::Kind::Type:
{
- auto type = ASTLoweringType::translate (arg.get_type ());
- type_args.emplace_back (std::unique_ptr<HIR::Type> (type));
+ type_args.emplace_back (
+ ASTLoweringType::translate (arg.get_type ()));
break;
}
case AST::GenericArg::Kind::Const:
{
auto expr = ASTLoweringExpr::translate (arg.get_expression ());
- const_args.emplace_back (
- HIR::ConstGenericArg (std::unique_ptr<HIR::Expr> (expr),
- expr->get_locus ()));
+ const_args.emplace_back (std::unique_ptr<HIR::Expr> (expr),
+ expr->get_locus ());
break;
}
default:
AST::TuplePatternItemsMultiple &pattern)
{
std::vector<std::unique_ptr<HIR::Pattern>> patterns;
+ patterns.reserve (pattern.get_patterns ().size ());
+
for (auto &p : pattern.get_patterns ())
- {
- HIR::Pattern *translated = ASTLoweringPattern::translate (*p);
- patterns.push_back (std::unique_ptr<HIR::Pattern> (translated));
- }
+ patterns.emplace_back (ASTLoweringPattern::translate (*p));
return std::unique_ptr<HIR::TuplePatternItems> (
new HIR::TuplePatternItemsNoRest (std::move (patterns)));
AST::TuplePatternItemsRanged &pattern)
{
std::vector<std::unique_ptr<HIR::Pattern>> lower_patterns;
+ lower_patterns.reserve (pattern.get_lower_patterns ().size ());
std::vector<std::unique_ptr<HIR::Pattern>> upper_patterns;
+ upper_patterns.reserve (pattern.get_upper_patterns ().size ());
for (auto &p : pattern.get_lower_patterns ())
- {
- HIR::Pattern *translated = ASTLoweringPattern::translate (*p);
- lower_patterns.push_back (std::unique_ptr<HIR::Pattern> (translated));
- }
+ lower_patterns.emplace_back (ASTLoweringPattern::translate (*p));
for (auto &p : pattern.get_upper_patterns ())
- {
- HIR::Pattern *translated = ASTLoweringPattern::translate (*p);
- upper_patterns.push_back (std::unique_ptr<HIR::Pattern> (translated));
- }
+ upper_patterns.emplace_back (ASTLoweringPattern::translate (*p));
return std::unique_ptr<HIR::TuplePatternItems> (
new HIR::TuplePatternItemsHasRest (std::move (lower_patterns),
mappings.get_next_localdef_id (crate_num));
std::vector<std::unique_ptr<HIR::ExternalItem>> extern_items;
+ extern_items.reserve (extern_block.get_extern_items ().size ());
+
for (auto &item : extern_block.get_extern_items ())
{
if (item->is_marked_for_strip ())
continue;
- HIR::ExternalItem *lowered
- = ASTLoweringExternItem::translate (item.get (), mapping.get_hirid ());
- extern_items.push_back (std::unique_ptr<HIR::ExternalItem> (lowered));
+ extern_items.emplace_back (
+ ASTLoweringExternItem::translate (item.get (), mapping.get_hirid ()));
}
ABI abi = ABI::C;
item.get_visibility ().as_string ().c_str ());
std::vector<HIR::TupleField> fields;
+ fields.reserve (item.get_tuple_fields ().size ());
+
for (auto &field : item.get_tuple_fields ())
{
HIR::Visibility vis = translate_visibility (field.get_visibility ());
crate_num, field.get_node_id (), mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
- HIR::TupleField translated_field (field_mapping,
- std::unique_ptr<HIR::Type> (type),
- vis, field.get_locus (),
- field.get_outer_attrs ());
- fields.push_back (std::move (translated_field));
+ fields.emplace_back (field_mapping, std::unique_ptr<HIR::Type> (type),
+ vis, field.get_locus (), field.get_outer_attrs ());
}
translated
ASTLoweringExpr::visit (AST::TupleExpr &expr)
{
std::vector<std::unique_ptr<HIR::Expr>> tuple_elements;
+ tuple_elements.reserve (expr.get_tuple_elems ().size ());
+
for (auto &e : expr.get_tuple_elems ())
- {
- HIR::Expr *t = ASTLoweringExpr::translate (*e);
- tuple_elements.push_back (std::unique_ptr<HIR::Expr> (t));
- }
+ tuple_elements.emplace_back (ASTLoweringExpr::translate (*e));
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
HIR::Expr *func = ASTLoweringExpr::translate (expr.get_function_expr ());
auto const &in_params = expr.get_params ();
+
std::vector<std::unique_ptr<HIR::Expr>> params;
+ params.reserve (in_params.size ());
+
for (auto ¶m : in_params)
- {
- auto trans = ASTLoweringExpr::translate (*param);
- params.push_back (std::unique_ptr<HIR::Expr> (trans));
- }
+ params.emplace_back (ASTLoweringExpr::translate (*param));
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (
auto const &in_params = expr.get_params ();
std::vector<std::unique_ptr<HIR::Expr>> params;
+ params.reserve (in_params.size ());
+
for (auto ¶m : in_params)
- {
- auto trans = ASTLoweringExpr::translate (*param);
- params.push_back (std::unique_ptr<HIR::Expr> (trans));
- }
+ params.emplace_back (ASTLoweringExpr::translate (*param));
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
ASTLoweringExpr::visit (AST::ArrayElemsValues &elems)
{
std::vector<std::unique_ptr<HIR::Expr>> elements;
+ elements.reserve (elems.get_values ().size ());
+
for (auto &elem : elems.get_values ())
- {
- HIR::Expr *translated_elem = ASTLoweringExpr::translate (*elem);
- elements.push_back (std::unique_ptr<HIR::Expr> (translated_elem));
- }
+ elements.emplace_back (ASTLoweringExpr::translate (*elem));
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (mappings.get_current_crate (),
}
auto const &in_fields = struct_expr.get_fields ();
+
std::vector<std::unique_ptr<HIR::StructExprField>> fields;
+ fields.reserve (in_fields.size ());
+
for (auto &field : in_fields)
- {
- HIR::StructExprField *translated
- = ASTLowerStructExprField::translate (*field);
- fields.push_back (std::unique_ptr<HIR::StructExprField> (translated));
- }
+ fields.emplace_back (ASTLowerStructExprField::translate (*field));
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, struct_expr.get_node_id (),
= ASTLoweringExpr::translate (expr.get_definition_expr ());
std::vector<HIR::ClosureParam> closure_params;
+ closure_params.reserve (expr.get_params ().size ());
+
for (auto ¶m : expr.get_params ())
- {
- HIR::ClosureParam p = lower_closure_param (param);
- closure_params.push_back (std::move (p));
- }
+ closure_params.emplace_back (lower_closure_param (param));
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
= ASTLoweringExpr::translate (expr.get_definition_expr ());
std::vector<HIR::ClosureParam> closure_params;
+ closure_params.reserve (expr.get_params ().size ());
+
for (auto ¶m : expr.get_params ())
- {
- HIR::ClosureParam p = lower_closure_param (param);
- closure_params.push_back (std::move (p));
- }
+ closure_params.emplace_back (lower_closure_param (param));
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings.get_next_localdef_id (crate_num));
std::vector<LlvmOperand> inputs;
+ inputs.reserve (expr.get_inputs ().size ());
+
std::vector<LlvmOperand> outputs;
+ outputs.reserve (expr.get_outputs ().size ());
for (auto i : expr.get_inputs ())
{
mappings.get_next_localdef_id (
crate_num));
- function_params.push_back (
- HIR::NamedFunctionParam (mapping, param_name,
- std::unique_ptr<HIR::Type> (param_type)));
+ function_params.emplace_back (mapping, param_name,
+ std::unique_ptr<HIR::Type> (param_type));
}
auto crate_num = mappings.get_current_crate ();
{
HIR::WhereClauseItem *i
= ASTLowerWhereClauseItem::translate (*item.get ());
- where_clause_items.push_back (std::unique_ptr<HIR::WhereClauseItem> (i));
+ where_clause_items.emplace_back (i);
}
HIR::WhereClause where_clause (std::move (where_clause_items));
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
- auto hir_param
- = HIR::FunctionParam (mapping, std::move (translated_pattern),
- std::move (translated_type), param.get_locus ());
- function_params.push_back (std::move (hir_param));
+ function_params.emplace_back (mapping, std::move (translated_pattern),
+ std::move (translated_type),
+ param.get_locus ());
}
bool terminated = false;
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
- auto hir_param
- = HIR::FunctionParam (mapping, std::move (translated_pattern),
- std::move (translated_type), param.get_locus ());
- function_params.push_back (std::move (hir_param));
+ function_params.emplace_back (mapping, std::move (translated_pattern),
+ std::move (translated_type),
+ param.get_locus ());
}
if (func.has_self_param ())
// The item may be null if it doesn't need to live in the HIR - for
// example, macro rules definitions
if (transitem)
- items.push_back (std::unique_ptr<Item> (transitem));
+ items.emplace_back (transitem);
}
// should be lowered/copied from module.get_in/outer_attrs()
ASTLoweringItem::visit (AST::TypeAlias &alias)
{
std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
+ where_clause_items.reserve (alias.get_where_clause ().get_items ().size ());
+
for (auto &item : alias.get_where_clause ().get_items ())
- {
- HIR::WhereClauseItem *i
- = ASTLowerWhereClauseItem::translate (*item.get ());
- where_clause_items.push_back (std::unique_ptr<HIR::WhereClauseItem> (i));
- }
+ where_clause_items.emplace_back (
+ ASTLowerWhereClauseItem::translate (*item.get ()));
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::Visibility vis = translate_visibility (alias.get_visibility ());
}
std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
+ where_clause_items.reserve (
+ struct_decl.get_where_clause ().get_items ().size ());
+
for (auto &item : struct_decl.get_where_clause ().get_items ())
- {
- HIR::WhereClauseItem *i
- = ASTLowerWhereClauseItem::translate (*item.get ());
- where_clause_items.push_back (std::unique_ptr<HIR::WhereClauseItem> (i));
- }
+ where_clause_items.emplace_back (
+ ASTLowerWhereClauseItem::translate (*item.get ()));
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::Visibility vis = translate_visibility (struct_decl.get_visibility ());
std::vector<HIR::TupleField> fields;
+ fields.reserve (struct_decl.get_fields ().size ());
+
for (AST::TupleField &field : struct_decl.get_fields ())
{
if (field.get_field_type ().is_marked_for_strip ())
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
- HIR::TupleField translated_field (mapping,
- std::unique_ptr<HIR::Type> (type), vis,
- field.get_locus (),
- field.get_outer_attrs ());
- fields.push_back (std::move (translated_field));
+ fields.emplace_back (mapping, std::unique_ptr<HIR::Type> (type), vis,
+ field.get_locus (), field.get_outer_attrs ());
}
auto crate_num = mappings.get_current_crate ();
}
std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
+ where_clause_items.reserve (
+ struct_decl.get_where_clause ().get_items ().size ());
+
for (auto &item : struct_decl.get_where_clause ().get_items ())
- {
- HIR::WhereClauseItem *i
- = ASTLowerWhereClauseItem::translate (*item.get ());
- where_clause_items.push_back (std::unique_ptr<HIR::WhereClauseItem> (i));
- }
+ where_clause_items.emplace_back (
+ ASTLowerWhereClauseItem::translate (*item.get ()));
HIR::WhereClause where_clause (std::move (where_clause_items));
}
std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
+ where_clause_items.reserve (
+ enum_decl.get_where_clause ().get_items ().size ());
+
for (auto &item : enum_decl.get_where_clause ().get_items ())
- {
- HIR::WhereClauseItem *i
- = ASTLowerWhereClauseItem::translate (*item.get ());
- where_clause_items.push_back (std::unique_ptr<HIR::WhereClauseItem> (i));
- }
+ where_clause_items.emplace_back (
+ ASTLowerWhereClauseItem::translate (*item.get ()));
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::Visibility vis = translate_visibility (enum_decl.get_visibility ());
// bool is_unit = enum_decl.is_zero_variant ();
std::vector<std::unique_ptr<HIR::EnumItem>> items;
+ items.reserve (enum_decl.get_variants ().size ());
+
for (auto &variant : enum_decl.get_variants ())
{
if (variant->is_marked_for_strip ())
continue;
- HIR::EnumItem *hir_item = ASTLoweringEnumItem::translate (variant.get ());
- items.push_back (std::unique_ptr<HIR::EnumItem> (hir_item));
+ items.emplace_back (ASTLoweringEnumItem::translate (variant.get ()));
}
auto crate_num = mappings.get_current_crate ();
{
std::vector<std::unique_ptr<HIR::GenericParam>> generic_params;
if (union_decl.has_generics ())
- {
- generic_params = lower_generic_params (union_decl.get_generic_params ());
- }
+ generic_params = lower_generic_params (union_decl.get_generic_params ());
std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
+ where_clause_items.reserve (
+ union_decl.get_where_clause ().get_items ().size ());
+
for (auto &item : union_decl.get_where_clause ().get_items ())
- {
- HIR::WhereClauseItem *i
- = ASTLowerWhereClauseItem::translate (*item.get ());
- where_clause_items.push_back (std::unique_ptr<HIR::WhereClauseItem> (i));
- }
+ where_clause_items.emplace_back (
+ ASTLowerWhereClauseItem::translate (*item.get ()));
+
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::Visibility vis = translate_visibility (union_decl.get_visibility ());
return;
std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
+ where_clause_items.reserve (
+ function.get_where_clause ().get_items ().size ());
+
for (auto &item : function.get_where_clause ().get_items ())
- {
- HIR::WhereClauseItem *i
- = ASTLowerWhereClauseItem::translate (*item.get ());
- where_clause_items.push_back (std::unique_ptr<HIR::WhereClauseItem> (i));
- }
+ where_clause_items.emplace_back (
+ ASTLowerWhereClauseItem::translate (*item.get ()));
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::FunctionQualifiers qualifiers
: nullptr;
std::vector<HIR::FunctionParam> function_params;
+ function_params.reserve (function.get_function_params ().size ());
+
for (auto &p : function.get_function_params ())
{
if (p->is_variadic () || p->is_self ())
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
- auto hir_param
- = HIR::FunctionParam (mapping, std::move (translated_pattern),
- std::move (translated_type), param.get_locus ());
- function_params.push_back (std::move (hir_param));
+ function_params.emplace_back (mapping, std::move (translated_pattern),
+ std::move (translated_type),
+ param.get_locus ());
}
bool terminated = false;
ASTLoweringItem::visit (AST::InherentImpl &impl_block)
{
std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
+ where_clause_items.reserve (
+ impl_block.get_where_clause ().get_items ().size ());
+
for (auto &item : impl_block.get_where_clause ().get_items ())
- {
- HIR::WhereClauseItem *i = ASTLowerWhereClauseItem::translate (*item);
- where_clause_items.push_back (std::unique_ptr<HIR::WhereClauseItem> (i));
- }
+ where_clause_items.emplace_back (
+ ASTLowerWhereClauseItem::translate (*item));
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::Visibility vis = translate_visibility (impl_block.get_visibility ());
HIR::ImplItem *lowered
= ASTLowerImplItem::translate (*impl_item, mapping.get_hirid ());
rust_assert (lowered != nullptr);
- impl_items.push_back (std::unique_ptr<HIR::ImplItem> (lowered));
+ impl_items.emplace_back (lowered);
impl_item_ids.push_back (lowered->get_impl_mappings ().get_hirid ());
}
ASTLoweringItem::visit (AST::Trait &trait)
{
std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
+ where_clause_items.reserve (trait.get_where_clause ().get_items ().size ());
+
for (auto &item : trait.get_where_clause ().get_items ())
- {
- HIR::WhereClauseItem *i
- = ASTLowerWhereClauseItem::translate (*item.get ());
- where_clause_items.push_back (std::unique_ptr<HIR::WhereClauseItem> (i));
- }
+ where_clause_items.emplace_back (
+ ASTLowerWhereClauseItem::translate (*item.get ()));
+
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::Visibility vis = translate_visibility (trait.get_visibility ());
if (trait.has_type_param_bounds ())
{
for (auto &bound : trait.get_type_param_bounds ())
- {
- HIR::TypeParamBound *b = lower_bound (*bound);
- type_param_bounds.push_back (
- std::unique_ptr<HIR::TypeParamBound> (b));
- }
+ type_param_bounds.emplace_back (lower_bound (*bound));
}
+ auto trait_item_size = trait.get_trait_items ().size ();
+
std::vector<std::unique_ptr<HIR::TraitItem>> trait_items;
+ trait_items.reserve (trait_item_size);
std::vector<HirId> trait_item_ids;
+ trait_item_ids.reserve (trait_item_size);
+
for (auto &item : trait.get_trait_items ())
{
if (item->is_marked_for_strip ())
continue;
HIR::TraitItem *lowered = ASTLowerTraitItem::translate (*item);
- trait_items.push_back (std::unique_ptr<HIR::TraitItem> (lowered));
trait_item_ids.push_back (lowered->get_mappings ().get_hirid ());
+ trait_items.emplace_back (lowered);
}
auto crate_num = mappings.get_current_crate ();
void
ASTLoweringItem::visit (AST::TraitImpl &impl_block)
{
- std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
bool unsafe = impl_block.is_unsafe ();
+
+ std::vector<std::unique_ptr<HIR::WhereClauseItem>> where_clause_items;
+ where_clause_items.reserve (
+ impl_block.get_where_clause ().get_items ().size ());
+
for (auto &item : impl_block.get_where_clause ().get_items ())
- {
- HIR::WhereClauseItem *i = ASTLowerWhereClauseItem::translate (*item);
- where_clause_items.push_back (std::unique_ptr<HIR::WhereClauseItem> (i));
- }
+ where_clause_items.emplace_back (
+ ASTLowerWhereClauseItem::translate (*item));
+
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::Visibility vis = translate_visibility (impl_block.get_visibility ());
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
+ auto impl_items_size = impl_block.get_impl_items ().size ();
+
std::vector<std::unique_ptr<HIR::ImplItem>> impl_items;
+ impl_items.reserve (impl_items_size);
std::vector<HirId> impl_item_ids;
+ impl_item_ids.reserve (impl_items_size);
+
for (auto &impl_item : impl_block.get_impl_items ())
{
if (impl_item->is_marked_for_strip ())
HIR::ImplItem *lowered
= ASTLowerImplItem::translate (*impl_item, mapping.get_hirid ());
rust_assert (lowered != nullptr);
- impl_items.push_back (std::unique_ptr<HIR::ImplItem> (lowered));
impl_item_ids.push_back (lowered->get_impl_mappings ().get_hirid ());
+ impl_items.emplace_back (lowered);
}
BoundPolarity polarity = impl_block.is_exclam ()
= static_cast<AST::TupleStructItemsNoRange &> (items);
std::vector<std::unique_ptr<HIR::Pattern>> patterns;
+ patterns.reserve (items_no_range.get_patterns ().size ());
+
for (auto &inner_pattern : items_no_range.get_patterns ())
- {
- HIR::Pattern *p = ASTLoweringPattern::translate (*inner_pattern);
- patterns.push_back (std::unique_ptr<HIR::Pattern> (p));
- }
+ patterns.emplace_back (
+ ASTLoweringPattern::translate (*inner_pattern));
lowered = new HIR::TupleStructItemsNoRest (std::move (patterns));
}
mappings.insert_node_to_hir (field_node_id, field_id);
// add it to the lowered fields list
- fields.push_back (std::unique_ptr<HIR::StructPatternField> (f));
+ fields.emplace_back (f);
}
auto crate_num = mappings.get_current_crate ();
AST::SlicePatternItemsNoRest &ref
= static_cast<AST::SlicePatternItemsNoRest &> (pattern.get_items ());
for (auto &p : ref.get_patterns ())
- {
- HIR::Pattern *item = ASTLoweringPattern::translate (*p);
- items.push_back (std::unique_ptr<HIR::Pattern> (item));
- }
+ items.emplace_back (ASTLoweringPattern::translate (*p));
}
break;
case AST::SlicePatternItems::SlicePatternItemType::HAS_REST:
UNKNOWN_LOCAL_DEFID);
std::vector<std::unique_ptr<HIR::Pattern>> alts;
+ alts.reserve (pattern.get_alts ().size ());
for (auto &alt : pattern.get_alts ())
- {
- alts.push_back (
- std::unique_ptr<HIR::Pattern> (ASTLoweringPattern::translate (*alt)));
- }
+ alts.emplace_back (ASTLoweringPattern::translate (*alt));
translated
= new HIR::AltPattern (mapping, std::move (alts), pattern.get_locus ());
{
auto translated = ASTLoweringItem::translate (*item);
if (translated != nullptr)
- items.push_back (std::unique_ptr<HIR::Item> (translated));
+ items.emplace_back (translated);
}
auto &mappings = Analysis::Mappings::get ();
block_did_terminate |= terminated;
if (translated_stmt)
- block_stmts.push_back (std::unique_ptr<HIR::Stmt> (translated_stmt));
+ block_stmts.emplace_back (translated_stmt);
}
if (expr.has_tail_expr () && block_did_terminate)
{
HIR::Expr *kase_expr;
std::vector<std::unique_ptr<HIR::Pattern>> match_arm_patterns;
+ match_arm_patterns.reserve (expr.get_patterns ().size ());
*branch_value = ASTLoweringExpr::translate (expr.get_value_expr ());
kase_expr = ASTLoweringExpr::translate (expr.get_if_block ());
rust_assert (expr.get_patterns ().size () == 1);
for (auto &pattern : expr.get_patterns ())
- {
- HIR::Pattern *ptrn = ASTLoweringPattern::translate (*pattern);
- match_arm_patterns.push_back (std::unique_ptr<HIR::Pattern> (ptrn));
- }
+ match_arm_patterns.emplace_back (ASTLoweringPattern::translate (*pattern));
// The match arm corresponding to the if let pattern when it matches.
HIR::MatchArm arm (std::move (match_arm_patterns), expr.get_locus (), nullptr,
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
- HIR::MatchCase kase (std::move (mapping), std::move (arm),
- std::unique_ptr<HIR::Expr> (kase_expr));
- match_arms.push_back (std::move (kase));
+ match_arms.emplace_back (std::move (mapping), std::move (arm),
+ std::unique_ptr<HIR::Expr> (kase_expr));
// The default match arm when the if let pattern does not match
std::vector<std::unique_ptr<HIR::Pattern>> match_arm_patterns_wildcard;
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
- std::unique_ptr<HIR::WildcardPattern> wc
- = std::unique_ptr<HIR::WildcardPattern> (
- new HIR::WildcardPattern (mapping_default, expr.get_locus ()));
-
- match_arm_patterns_wildcard.push_back (std::move (wc));
+ match_arm_patterns_wildcard.emplace_back (
+ new HIR::WildcardPattern (mapping_default, expr.get_locus ()));
HIR::MatchArm arm_default (std::move (match_arm_patterns_wildcard),
expr.get_locus (), nullptr, {});
- HIR::MatchCase kase_else (std::move (mapping_default),
- std::move (arm_default),
- std::unique_ptr<HIR::Expr> (kase_else_expr));
- match_arms.push_back (std::move (kase_else));
+ match_arms.emplace_back (std::move (mapping_default), std::move (arm_default),
+ std::unique_ptr<HIR::Expr> (kase_else_expr));
}
void
}
std::vector<std::unique_ptr<HIR::Pattern>> match_arm_patterns;
+ match_arm_patterns.reserve (
+ match_case.get_arm ().get_patterns ().size ());
+
for (auto &pattern : match_case.get_arm ().get_patterns ())
- {
- HIR::Pattern *ptrn = ASTLoweringPattern::translate (*pattern);
- match_arm_patterns.push_back (std::unique_ptr<HIR::Pattern> (ptrn));
- }
+ match_arm_patterns.emplace_back (
+ ASTLoweringPattern::translate (*pattern));
HIR::MatchArm arm (std::move (match_arm_patterns), expr.get_locus (),
std::unique_ptr<HIR::Expr> (kase_guard_expr),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
- HIR::MatchCase kase (std::move (mapping), std::move (arm),
- std::unique_ptr<HIR::Expr> (kase_expr));
- match_arms.push_back (std::move (kase));
+ match_arms.emplace_back (std::move (mapping), std::move (arm),
+ std::unique_ptr<HIR::Expr> (kase_expr));
}
auto crate_num = mappings.get_current_crate ();
return;
}
- std::vector<HIR::PathExprSegment> path_segments;
auto &segments = expr.get_segments ();
+
+ std::vector<HIR::PathExprSegment> path_segments;
+ path_segments.reserve (segments.size ());
+
for (auto &s : segments)
{
path_segments.push_back (lower_path_expr_seg ((s)));
HIR::QualifiedPathType qual_path_type
= lower_qual_path_type (expr.get_qualified_path_type ());
- std::vector<HIR::PathExprSegment> path_segments;
auto &segments = expr.get_segments ();
+
+ std::vector<HIR::PathExprSegment> path_segments;
+ path_segments.reserve (segments.size ());
+
for (auto &s : segments)
{
path_segments.push_back (lower_path_expr_seg ((s)));
// create segment and add to vector
std::string segment_str = segment.as_string ();
- simple_segments.push_back (
- AST::SimplePathSegment (std::move (segment_str), segment.get_locus ()));
+ simple_segments.emplace_back (std::move (segment_str),
+ segment.get_locus ());
}
// kind of a HACK to get locus depending on opening scope resolution
// create segment and add to vector
std::string segment_str = segment->as_string ();
- simple_segments.push_back (
- AST::SimplePathSegment (std::move (segment_str),
- segment->get_locus ()));
+ simple_segments.emplace_back (std::move (segment_str),
+ segment->get_locus ());
}
return AST::SimplePath (std::move (simple_segments),
AST::Function &function = static_cast<AST::Function &> (vis_item);
std::vector<std::unique_ptr<AST::ExternalItem>> external_items;
- external_items.push_back (std::unique_ptr<AST::ExternalItem> (
- static_cast<AST::ExternalItem *> (&function)));
+ external_items.emplace_back (
+ static_cast<AST::ExternalItem *> (&function));
AST::ExternBlock extern_block (get_string_from_abi (Rust::ABI::RUST),
std::move (external_items),
return nullptr;
}
- AST::MacroRule macro_rule
- = AST::MacroRule (std::move (matcher), std::move (transcriber), locus);
std::vector<AST::MacroRule> macro_rules;
- macro_rules.push_back (macro_rule);
+ macro_rules.emplace_back (std::move (matcher), std::move (transcriber),
+ locus);
return std::unique_ptr<AST::MacroRulesDefinition> (
AST::MacroRulesDefinition::decl_macro (std::move (rule_name),
break;
}
- lifetime_params.push_back (std::unique_ptr<AST::LifetimeParam> (
- new AST::LifetimeParam (std::move (lifetime_param.value ()))));
+ lifetime_params.emplace_back (
+ new AST::LifetimeParam (std::move (lifetime_param.value ())));
if (lexer.peek_token ()->get_id () != COMMA)
break;
return {};
}
- lifetime_params.push_back (std::unique_ptr<AST::LifetimeParam> (
- new AST::LifetimeParam (std::move (lifetime_param))));
+ lifetime_params.emplace_back (
+ new AST::LifetimeParam (std::move (lifetime_param)));
if (lexer.peek_token ()->get_id () != COMMA)
break;
{
// here we implicitly make self have a type path of Self
std::vector<std::unique_ptr<AST::TypePathSegment>> segments;
- segments.push_back (std::unique_ptr<AST::TypePathSegment> (
- new AST::TypePathSegment ("Self", false, param.get_locus ())));
+ segments.emplace_back (
+ new AST::TypePathSegment ("Self", false, param.get_locus ()));
AST::TypePath self_type_path (std::move (segments),
param.get_locus ());
{
// here we implicitly make self have a type path of Self
std::vector<std::unique_ptr<AST::TypePathSegment>> segments;
- segments.push_back (std::unique_ptr<AST::TypePathSegment> (
- new AST::TypePathSegment ("Self", false, self_param.get_locus ())));
+ segments.emplace_back (
+ new AST::TypePathSegment ("Self", false, self_param.get_locus ()));
AST::TypePath self_type_path (std::move (segments),
self_param.get_locus ());
= AST::SimplePath ({}, prefix.has_opening_scope_resolution (),
prefix.get_locus ());
for (auto &seg : prefix.get_segments ())
- prefix_copy.get_segments ().push_back (
- AST::SimplePathSegment (seg.get_segment_name (),
- seg.get_locus ()));
+ prefix_copy.get_segments ().emplace_back (seg.get_segment_name (),
+ seg.get_locus ());
import->add_prefix (std::move (prefix_copy));
}
// push a new set of 'Or' bindings to the stack. Accounts for the
// alternatives. e.g. in `p_0 | p_1`, bindings to the same identifier between
// p_0 and p_1 shouldn't cause an error.
- bindings_with_ctx.push_back (
- PatternBinding (PatternBoundCtx::Or, std::set<Identifier> ()));
+ bindings_with_ctx.emplace_back (PatternBoundCtx::Or, std::set<Identifier> ());
// This is a hack to avoid creating a separate visitor class for the
// consistency checks. We empty out the binding_info_map before each iteration
// push a new `Product` context to correctly reject multiple bindings
// within this single alt.
- bindings_with_ctx.push_back (
- PatternBinding (PatternBoundCtx::Product, std::set<Identifier> ()));
+ bindings_with_ctx.emplace_back (PatternBoundCtx::Product,
+ std::set<Identifier> ());
alt->accept_vis (*this);
TyTy::ReferenceType *r1
= new TyTy::ReferenceType (r->get_ref (), TyTy::TyVar (r->get_ref ()),
Mutability::Imm);
- adjustments.push_back (
- Adjustment (Adjustment::AdjustmentType::IMM_REF, r, r1));
+ adjustments.emplace_back (Adjustment::AdjustmentType::IMM_REF, r, r1);
if (select (*r1))
return true;
TyTy::ReferenceType *r2
= new TyTy::ReferenceType (r->get_ref (), TyTy::TyVar (r->get_ref ()),
Mutability::Mut);
- adjustments.push_back (
- Adjustment (Adjustment::AdjustmentType::MUT_REF, r, r2));
+ adjustments.emplace_back (Adjustment::AdjustmentType::MUT_REF, r, r2);
if (select (*r2))
return true;
needs_reborrow = true;
expected_mutability = to_mutbl;
- adjustments.push_back (
- Adjustment (Adjustment::AdjustmentType::INDIRECTION, source_ref, ty_a));
+ adjustments.emplace_back (Adjustment::AdjustmentType::INDIRECTION,
+ source_ref, ty_a);
}
else if (source_is_ref && target_is_ptr)
{
needs_reborrow = true;
expected_mutability = to_mutbl;
- adjustments.push_back (
- Adjustment (Adjustment::AdjustmentType::INDIRECTION, source_ref, ty_a));
+ adjustments.emplace_back (Adjustment::AdjustmentType::INDIRECTION,
+ source_ref, ty_a);
}
// FIXME
// result->set_ref (a->get_ref ());
// append a dyn coercion adjustment
- adjustments.push_back (Adjustment (Adjustment::UNSIZE, a, result));
+ adjustments.emplace_back (Adjustment::UNSIZE, a, result);
// reborrow if needed
if (needs_reborrow)
Adjustment::AdjustmentType borrow_type
= expected_mutability == Mutability::Imm ? Adjustment::IMM_REF
: Adjustment::MUT_REF;
- adjustments.push_back (Adjustment (borrow_type, result, reborrow));
+ adjustments.emplace_back (borrow_type, result, reborrow);
result = reborrow;
}
return true;
}
- inherent_impl_fns.push_back ({func, impl, fnty});
+ inherent_impl_fns.emplace_back (func, impl, fnty);
return true;
});
continue;
}
- impl_candidates.push_back ({func, impl, fnty});
+ impl_candidates.emplace_back (func, impl, fnty);
return true;
}
rust_assert (ty->get_kind () == TyTy::TypeKind::FNDEF);
TyTy::FnType *fnty = static_cast<TyTy::FnType *> (ty);
- trait_item_candidate candidate{func, trait, fnty, trait_ref, item_ref};
- trait_candidates.push_back (candidate);
+ trait_candidates.emplace_back (func, trait, fnty, trait_ref, item_ref);
return true;
});
{
TyTy::FnType *fnty = static_cast<TyTy::FnType *> (ty);
if (fnty->is_method ())
- {
- predicate_candidate candidate{lookup, fnty};
- predicate_items.push_back (candidate);
- }
+ predicate_items.emplace_back (lookup, fnty);
}
}
public:
struct predicate_candidate
{
+ predicate_candidate (TyTy::TypeBoundPredicateItem lookup,
+ TyTy::FnType *fntype)
+ : lookup (lookup), fntype (fntype)
+ {}
TyTy::TypeBoundPredicateItem lookup;
TyTy::FnType *fntype;
};
struct impl_item_candidate
{
+ impl_item_candidate (HIR::Function *item, HIR::ImplBlock *impl_block,
+ TyTy::FnType *ty)
+ : item (item), impl_block (impl_block), ty (ty)
+ {}
+
HIR::Function *item;
HIR::ImplBlock *impl_block;
TyTy::FnType *ty;
struct trait_item_candidate
{
+ trait_item_candidate (const HIR::TraitItemFunc *item,
+ const HIR::Trait *trait, TyTy::FnType *ty,
+ const TraitReference *reference,
+ const TraitItemReference *item_ref)
+ : item (item), trait (trait), ty (ty), reference (reference),
+ item_ref (item_ref)
+ {}
const HIR::TraitItemFunc *item;
const HIR::Trait *trait;
TyTy::FnType *ty;
}
std::vector<std::pair<const TraitReference *, HIR::ImplBlock *>> union_set;
+
for (auto it = mapper.begin (); it != mapper.end (); it++)
- {
- union_set.push_back ({it->second.first, it->second.second});
- }
+ union_set.emplace_back (it->second.first, it->second.second);
+
return union_set;
}
apply_sized);
context->insert_type (generic_param->get_mappings (), param_type);
- substitutions.push_back (
- TyTy::SubstitutionParamMapping (typaram, param_type));
+ substitutions.emplace_back (typaram, param_type);
if (is_self)
{
// copy the substitition mappings
std::vector<TyTy::SubstitutionParamMapping> self_subst_copy;
+ self_subst_copy.reserve (substitutions.size ());
+
for (auto &sub : substitutions)
self_subst_copy.push_back (sub.clone ());
{
// make a copy of the substs
std::vector<TyTy::SubstitutionParamMapping> item_subst;
+ item_subst.reserve (substitutions.size ());
+
for (auto &sub : substitutions)
item_subst.push_back (sub.clone ());
generic_param->get_mappings ().get_hirid (), &l);
if (ok && l->get_kind () == TyTy::TypeKind::PARAM)
{
- substitutions.push_back (TyTy::SubstitutionParamMapping (
- static_cast<HIR::TypeParam &> (*generic_param),
- static_cast<TyTy::ParamType *> (l)));
+ substitutions.emplace_back (static_cast<HIR::TypeParam &> (
+ *generic_param),
+ static_cast<TyTy::ParamType *> (l));
}
}
break;
if (p.needs_substitution () && infer)
{
TyTy::TyVar infer_var = TyTy::TyVar::get_implicit_infer_var (locus);
- subst_args.push_back (
- TyTy::SubstitutionArg (&p, infer_var.get_tyty ()));
+ subst_args.emplace_back (&p, infer_var.get_tyty ());
}
else
{
auto param = p.get_param_ty ();
auto resolved = param->destructure ();
- subst_args.push_back (TyTy::SubstitutionArg (&p, resolved));
+ subst_args.emplace_back (&p, resolved);
param_mappings[param->get_symbol ()] = resolved->get_ref ();
}
}
for (auto &elem : expr.get_tuple_elems ())
{
auto field_ty = TypeCheckExpr::Resolve (*elem);
- fields.push_back (TyTy::TyVar (field_ty->get_ref ()));
+ fields.emplace_back (field_ty->get_ref ());
}
infered = new TyTy::TupleType (expr.get_mappings ().get_hirid (),
expr.get_locus (), fields);
// substitute it in
std::vector<TyTy::SubstitutionArg> subst_mappings;
const TyTy::SubstitutionParamMapping *param_ref = &adt->get_substs ().at (0);
- subst_mappings.push_back (TyTy::SubstitutionArg (param_ref, unified));
+ subst_mappings.emplace_back (param_ref, unified);
TyTy::SubstitutionArgumentMappings subst (
subst_mappings, {}, adt->get_substitution_arguments ().get_regions (),
// substitute it in
std::vector<TyTy::SubstitutionArg> subst_mappings;
const TyTy::SubstitutionParamMapping *param_ref = &adt->get_substs ().at (0);
- subst_mappings.push_back (TyTy::SubstitutionArg (param_ref, from_ty));
+ subst_mappings.emplace_back (param_ref, from_ty);
TyTy::SubstitutionArgumentMappings subst (
subst_mappings, {}, adt->get_substitution_arguments ().get_regions (),
// substitute it in
std::vector<TyTy::SubstitutionArg> subst_mappings;
const TyTy::SubstitutionParamMapping *param_ref = &adt->get_substs ().at (0);
- subst_mappings.push_back (TyTy::SubstitutionArg (param_ref, from_ty));
+ subst_mappings.emplace_back (param_ref, from_ty);
TyTy::SubstitutionArgumentMappings subst (
subst_mappings, {}, adt->get_substitution_arguments ().get_regions (),
// substitute it in
std::vector<TyTy::SubstitutionArg> subst_mappings;
const TyTy::SubstitutionParamMapping *param_ref = &adt->get_substs ().at (0);
- subst_mappings.push_back (TyTy::SubstitutionArg (param_ref, unified));
+ subst_mappings.emplace_back (param_ref, unified);
TyTy::SubstitutionArgumentMappings subst (
subst_mappings, {}, adt->get_substitution_arguments ().get_regions (),
// auto resolve because the hir id's match
,
expr.get_locus ());
- args.get_type_args ().push_back (std::unique_ptr<HIR::Type> (implicit_tuple));
+ args.get_type_args ().emplace_back (implicit_tuple);
// apply the arguments
predicate.apply_generic_arguments (&args, false, false);
std::vector<TyTy::SubstitutionArg> mappings;
auto &self_param_mapping = trait_subst[0];
- mappings.push_back (TyTy::SubstitutionArg (&self_param_mapping, lhs));
+ mappings.emplace_back (&self_param_mapping, lhs);
if (rhs != nullptr)
{
rust_assert (trait_subst.size () == 2);
auto &rhs_param_mapping = trait_subst[1];
- mappings.push_back (TyTy::SubstitutionArg (&rhs_param_mapping, lhs));
+ mappings.emplace_back (&rhs_param_mapping, lhs);
}
std::map<std::string, TyTy::BaseType *> binding_args;
for (auto &arg : expr.get_arguments ())
{
TyTy::BaseType *a = TypeCheckExpr::Resolve (*arg);
- call_args.push_back (TyTy::TyVar (a->get_ref ()));
+ call_args.emplace_back (a->get_ref ());
}
// crate implicit tuple
context->insert_implicit_type (implicit_arg_id, tuple);
std::vector<TyTy::Argument> args;
- TyTy::Argument a (mapping, tuple,
- expr.get_locus () /*FIXME is there a better location*/);
- args.push_back (std::move (a));
+ args.emplace_back (mapping, tuple,
+ expr.get_locus () /*FIXME is there a better location*/);
TyTy::BaseType *function_ret_tyty
= TyTy::TypeCheckMethodCallExpr::go (fn, expr.get_mappings (), args,
UNDEF_LOCATION, false, Mutability::Imm,
std::unique_ptr<HIR::Pattern> (nullptr)));
- params.push_back (TyTy::FnParam (std::move (param_pattern), param_tyty));
+ params.emplace_back (std::move (param_pattern), param_tyty);
context->insert_type (param.get_mappings (), param_tyty);
}
context->insert_type (self_param.get_mappings (), self_type);
- params.push_back (TyTy::FnParam (std::move (self_pattern), self_type));
+ params.emplace_back (std::move (self_pattern), self_type);
}
for (auto ¶m : function.get_function_params ())
context->insert_type (param.get_mappings (), param_tyty);
TypeCheckPattern::Resolve (param.get_param_name (), param_tyty);
- params.push_back (
- TyTy::FnParam (param.get_param_name ().clone_pattern (), param_tyty));
+ params.emplace_back (param.get_param_name ().clone_pattern (),
+ param_tyty);
}
auto &nr_ctx
if (p.needs_substitution ())
{
TyTy::TyVar infer_var = TyTy::TyVar::get_implicit_infer_var (locus);
- args.push_back (TyTy::SubstitutionArg (&p, infer_var.get_tyty ()));
+ args.emplace_back (&p, infer_var.get_tyty ());
}
else
{
auto param = p.get_param_ty ();
auto resolved = param->destructure ();
- args.push_back (TyTy::SubstitutionArg (&p, resolved));
+ args.emplace_back (&p, resolved);
}
}
auto param_tyty = TypeCheckType::Resolve (param.get_type ());
context->insert_type (param.get_mappings (), param_tyty);
TypeCheckPattern::Resolve (param.get_param_name (), param_tyty);
- params.push_back (
- TyTy::FnParam (param.get_param_name ().clone_pattern (), param_tyty));
+ params.emplace_back (param.get_param_name ().clone_pattern (),
+ param_tyty);
}
auto &nr_ctx
TyTy::BaseType *par_type = par.get_field (i);
TyTy::BaseType *elem = TypeCheckPattern::Resolve (*p, par_type);
- pattern_elems.push_back (TyTy::TyVar (elem->get_ref ()));
+ pattern_elems.emplace_back (elem->get_ref ());
}
infered = new TyTy::TupleType (pattern.get_mappings ().get_hirid (),
pattern.get_locus (), pattern_elems);
TyTy::BaseType *par_type = par.get_field (i);
TyTy::BaseType *elem = TypeCheckPattern::Resolve (*p, par_type);
- pattern_elems.push_back (TyTy::TyVar (elem->get_ref ()));
+ pattern_elems.emplace_back (elem->get_ref ());
}
// Pad pattern_elems until needing to resolve upper patterns
for (size_t i = lower.size (); i < rest_end; i++)
{
TyTy::BaseType *par_type = par.get_field (i);
- pattern_elems.push_back (TyTy::TyVar (par_type->get_ref ()));
+ pattern_elems.emplace_back (par_type->get_ref ());
}
// Resolve upper patterns
TyTy::BaseType *par_type = par.get_field (rest_end + i);
TyTy::BaseType *elem = TypeCheckPattern::Resolve (*p, par_type);
- pattern_elems.push_back (TyTy::TyVar (elem->get_ref ()));
+ pattern_elems.emplace_back (elem->get_ref ());
}
infered = new TyTy::TupleType (pattern.get_mappings ().get_hirid (),
rust_assert (ok);
adtFieldIndexToField[field_index] = implicit_field;
- struct_expr.get_fields ().push_back (
- std::unique_ptr<HIR::StructExprField> (implicit_field));
+ struct_expr.get_fields ().emplace_back (implicit_field);
}
}
}
field.release ();
std::vector<std::unique_ptr<HIR::StructExprField> > ordered_fields;
+ ordered_fields.reserve (adtFieldIndexToField.size ());
+
for (size_t i = 0; i < adtFieldIndexToField.size (); i++)
- {
- ordered_fields.push_back (
- std::unique_ptr<HIR::StructExprField> (adtFieldIndexToField[i]));
- }
+ ordered_fields.emplace_back (adtFieldIndexToField[i]);
+
struct_expr.set_fields_as_owner (std::move (ordered_fields));
}
}
std::vector<TyTy::TyVar> params;
+ params.reserve (fntype.get_function_params ().size ());
+
for (auto ¶m : fntype.get_function_params ())
{
TyTy::BaseType *ptype = TypeCheckType::Resolve (param.get_type ());
- params.push_back (TyTy::TyVar (ptype->get_ref ()));
+ params.emplace_back (ptype->get_ref ());
}
translated = new TyTy::FnPtr (fntype.get_mappings ().get_hirid (),
}
std::vector<TyTy::TyVar> fields;
+ fields.reserve (tuple.get_elems ().size ());
+
for (auto &elem : tuple.get_elems ())
{
auto field_ty = TypeCheckType::Resolve (*elem);
- fields.push_back (TyTy::TyVar (field_ty->get_ref ()));
+ fields.emplace_back (field_ty->get_ref ());
}
translated = new TyTy::TupleType (tuple.get_mappings ().get_hirid (),
}
context->insert_type (self_param.get_mappings (), self_type);
- params.push_back (TyTy::FnParam (std::move (self_pattern), self_type));
+ params.emplace_back (std::move (self_pattern), self_type);
}
for (auto ¶m : function.get_function_params ())
context->insert_type (param.get_mappings (), param_tyty);
TypeCheckPattern::Resolve (param.get_param_name (), param_tyty);
// FIXME: Should we take the name ? Use a shared pointer instead ?
- params.push_back (
- TyTy::FnParam (param.get_param_name ().clone_pattern (), param_tyty));
+ params.emplace_back (param.get_param_name ().clone_pattern (),
+ param_tyty);
}
auto &nr_ctx
TypeCheckContext::push_return_type (TypeCheckContextItem item,
TyTy::BaseType *return_type)
{
- return_type_stack.push_back ({std::move (item), return_type});
+ return_type_stack.emplace_back (std::move (item), return_type);
}
void
associated_traits_to_impls[trait_id] = {};
}
- associated_traits_to_impls[trait_id].push_back ({impl_type, impl_id});
+ associated_traits_to_impls[trait_id].emplace_back (impl_type, impl_id);
}
bool
return true;
}
- possible_trait_paths.push_back ({&impl->get_trait_ref (), impl});
+ possible_trait_paths.emplace_back (&impl->get_trait_ref (), impl);
return true;
}
TraitReference *trait_ref = TraitResolver::Resolve (*trait_path);
if (!trait_ref->is_error ())
- trait_references.push_back ({trait_ref, path.second});
+ trait_references.emplace_back (trait_ref, path.second);
}
// marker traits...
{
auto trait_ref = TraitResolver::Resolve (*trait);
- trait_references.push_back ({trait_ref, mappings.lookup_builtin_marker ()});
+ trait_references.emplace_back (trait_ref, mappings.lookup_builtin_marker ());
}
void
std::vector<HIR::GenericArgsBinding> bindings;
location_t output_locus = fn.get_return_type ().get_locus ();
- HIR::GenericArgsBinding binding (Identifier (
- trait_item->trait_identifier ()),
- fn.get_return_type ().clone_type (),
- output_locus);
- bindings.push_back (std::move (binding));
+ bindings.emplace_back (Identifier (trait_item->trait_identifier ()),
+ fn.get_return_type ().clone_type (),
+ output_locus);
args = HIR::GenericArgs ({} /* lifetimes */,
std::move (inputs) /* type_args*/,
{
TyTy::BaseType *argument
= m.get_tyty () == nullptr ? nullptr : m.get_tyty ()->clone ();
- SubstitutionArg c (&substitutions.at (i++), argument);
- copied_arg_mappings.push_back (std::move (c));
+
+ copied_arg_mappings.emplace_back (&substitutions.at (i++), argument);
}
used_arguments
TyTy::BaseType *argument
= is_implicit_self ? receiver->clone () : mapping.get_tyty ();
- SubstitutionArg arg (mapping.get_param_mapping (), argument);
- adjusted_mappings.push_back (std::move (arg));
+ adjusted_mappings.emplace_back (mapping.get_param_mapping (), argument);
}
SubstitutionArgumentMappings adjusted (adjusted_mappings, {},
= trait_item.get_trait_item_type ()
== Resolver::TraitItemReference::TraitItemType::TYPE;
if (is_associated_type)
- {
- TypeBoundPredicateItem item (*this, &trait_item);
- items.push_back (std::move (item));
- }
+ items.emplace_back (*this, &trait_item);
}
return items;
}
return new ErrorType (ref->get_ref ());
}
- Argument a (arg->get_mappings (), argument_expr_tyty, arg->get_locus ());
- args.push_back (std::move (a));
+ args.emplace_back (arg->get_mappings (), argument_expr_tyty,
+ arg->get_locus ());
}
TypeCheckMethodCallExpr checker (call.get_mappings (), args,
SubstitutionRef::clone_substs () const
{
std::vector<SubstitutionParamMapping> clone;
+ clone.reserve (substitutions.size ());
for (auto &sub : substitutions)
clone.push_back (sub.clone ());
}
}
- SubstitutionArg subst_arg (¶m_mapping, resolved);
+ mappings.emplace_back (¶m_mapping, resolved);
offs++;
- mappings.push_back (std::move (subst_arg));
}
for (auto &arg : args.get_const_args ())
expr.get_mappings ().get_hirid (),
expr.get_mappings ().get_hirid (), {});
- SubstitutionArg subst_arg (¶m_mapping, const_value);
+ mappings.emplace_back (¶m_mapping, const_value);
offs++;
- mappings.push_back (std::move (subst_arg));
}
// we must need to fill out defaults
return SubstitutionArgumentMappings::error ();
}
- SubstitutionArg subst_arg (¶m, resolved);
- mappings.push_back (std::move (subst_arg));
+ mappings.emplace_back (¶m, resolved);
}
}
if (have_mapping)
{
- args.push_back (SubstitutionArg (&p, it->second));
+ args.emplace_back (&p, it->second);
}
else if (generic.get_kind () == HIR::GenericParam::GenericKind::TYPE)
{
TyVar infer_var = TyVar::get_implicit_infer_var (locus);
- args.push_back (SubstitutionArg (&p, infer_var.get_tyty ()));
+ args.emplace_back (&p, infer_var.get_tyty ());
argument_mappings[symbol] = infer_var.get_tyty ();
}
else if (generic.get_kind () == HIR::GenericParam::GenericKind::CONST)
TyVar infer_var
= TyVar::get_implicit_const_infer_var (const_type, locus);
- args.push_back (SubstitutionArg (&p, infer_var.get_tyty ()));
+ args.emplace_back (&p, infer_var.get_tyty ());
argument_mappings[symbol] = infer_var.get_tyty ();
}
}
else
{
- args.push_back (SubstitutionArg (&p, p.get_param_ty ()->resolve ()));
+ args.emplace_back (&p, p.get_param_ty ()->resolve ());
}
}
bool ok = !arg.is_error ();
if (ok || (trait_mode && i == 0))
- {
- SubstitutionArg adjusted (&subst, arg.get_tyty ());
- resolved_mappings.push_back (std::move (adjusted));
- }
+ resolved_mappings.emplace_back (&subst, arg.get_tyty ());
}
if (resolved_mappings.empty ())
bool ok = !arg.is_error ();
if (ok)
- {
- SubstitutionArg adjusted (&subst, arg.get_tyty ());
- resolved_mappings.push_back (std::move (adjusted));
- }
+ resolved_mappings.emplace_back (&subst, arg.get_tyty ());
}
return !resolved_mappings.empty ();
SubstitutionArg &arg = mappings.get_mappings ().at (i);
if (param_mapping.needs_substitution ())
- {
- SubstitutionArg adjusted (¶m_mapping, arg.get_tyty ());
- resolved_mappings.push_back (std::move (adjusted));
- }
+ resolved_mappings.emplace_back (¶m_mapping, arg.get_tyty ());
}
return SubstitutionArgumentMappings (resolved_mappings,
/** Variance constraint of a type parameter. */
struct Constraint
{
+ Constraint (SolutionIndex target_index, Term *term)
+ : target_index (target_index), term (term)
+ {}
+
SolutionIndex target_index;
Term *term;
};
auto num_types = type.get_num_type_params ();
std::vector<Variance> result;
+ result.reserve (num_lifetimes + num_types);
+
for (size_t i = 0; i < num_lifetimes + num_types; ++i)
{
result.push_back (solutions[solution_index.value () + i]);
}
else
{
- ctx.constraints.push_back ({index, new Term (term)});
+ ctx.constraints.emplace_back (index, new Term (term));
}
}
FnPtr::clone () const
{
std::vector<TyVar> cloned_params;
+ cloned_params.reserve (params.size ());
+
for (auto &p : params)
- cloned_params.push_back (TyVar (p.get_ref ()));
+ cloned_params.emplace_back (p.get_ref ());
return new FnPtr (get_ref (), get_ty_ref (), ident.locus,
std::move (cloned_params), result_type,
if (item->get_trait_item_type ()
== Resolver::TraitItemReference::TraitItemType::FN
&& item->is_object_safe ())
- items.push_back ({item, &bound});
+ items.emplace_back (item, &bound);
}
}
return items;
infers);
TyTy::BaseType *result = r.go ();
- commits.push_back ({lhs.get_ty (), rhs.get_ty (), result});
+ commits.emplace_back (lhs.get_ty (), rhs.get_ty (), result);
if (r.commit_flag)
UnifyRules::commit (lhs.get_ty (), rhs.get_ty (), result);
rust_assert (iv.get_tyty ()->get_kind () == TyTy::TypeKind::INFER);
TyTy::InferType *i = static_cast<TyTy::InferType *> (iv.get_tyty ());
- infers.push_back ({p->get_ref (), p->get_ty_ref (), p, i});
+ infers.emplace_back (p->get_ref (), p->get_ty_ref (), p, i);
// FIXME
// this is hacky to set the implicit param lets make this a function
rust_assert (iv.get_tyty ()->get_kind () == TyTy::TypeKind::INFER);
TyTy::InferType *i = static_cast<TyTy::InferType *> (iv.get_tyty ());
- infers.push_back ({p->get_ref (), p->get_ty_ref (), p, i});
+ infers.emplace_back (p->get_ref (), p->get_ty_ref (), p, i);
// FIXME
// this is hacky to set the implicit param lets make this a function
if (unified_ty->get_kind () == TyTy::TypeKind::ERROR)
return new TyTy::ErrorType (0);
- fields.push_back (TyTy::TyVar (unified_ty->get_ref ()));
+ fields.emplace_back (unified_ty->get_ref ());
}
return new TyTy::TupleType (type.get_ref (), type.get_ty_ref (),
public:
struct InferenceSite
{
+ InferenceSite (HirId pref, HirId ptyref, TyTy::ParamType *param,
+ TyTy::InferType *infer)
+ : pref (pref), ptyref (ptyref), param (param), infer (infer)
+ {}
+
HirId pref;
HirId ptyref;
TyTy::ParamType *param;
};
struct CommitSite
{
+ CommitSite (TyTy::BaseType *lhs, TyTy::BaseType *rhs,
+ TyTy::BaseType *resolved)
+ : lhs (lhs), rhs (rhs), resolved (resolved)
+ {}
+
TyTy::BaseType *lhs;
TyTy::BaseType *rhs;
TyTy::BaseType *resolved;
return CanonicalPath (other.segs, crate_num);
std::vector<std::pair<NodeId, std::string>> copy (segs);
+ copy.reserve (other.segs.size ());
+
for (auto &s : other.segs)
copy.push_back (s);
convert (const std::vector<const_TokenPtr> &tokens)
{
std::vector<ProcMacro::TokenStream> trees;
- trees.push_back (ProcMacro::TokenStream::make_tokenstream ());
+ trees.reserve (tokens.size ());
+
+ trees.emplace_back (ProcMacro::TokenStream::make_tokenstream ());
for (auto &token : tokens)
{
auto loc = convert (token->get_locus ());