@@ -554,12 +554,12 @@ std::unique_ptr<GenericParam>
554554Builder::new_lifetime_param (LifetimeParam ¶m)
555555{
556556 Lifetime l = new_lifetime (param.get_lifetime ());
557+
557558 std::vector<Lifetime> lifetime_bounds;
559+ lifetime_bounds.reserve (param.get_lifetime_bounds ().size ());
560+
558561 for (auto b : param.get_lifetime_bounds ())
559- {
560- Lifetime bl = new_lifetime (b);
561- lifetime_bounds.push_back (bl);
562- }
562+ lifetime_bounds.emplace_back (new_lifetime (b));
563563
564564 auto p = new LifetimeParam (l, std::move (lifetime_bounds),
565565 param.get_outer_attrs (), param.get_locus ());
@@ -605,11 +605,11 @@ Builder::new_type_param (
605605 for (const auto &lifetime : tb.get_for_lifetimes ())
606606 {
607607 std::vector<Lifetime> lifetime_bounds;
608+ lifetime_bounds.reserve (
609+ lifetime.get_lifetime_bounds ().size ());
610+
608611 for (const auto &b : lifetime.get_lifetime_bounds ())
609- {
610- Lifetime bl = new_lifetime (b);
611- lifetime_bounds.push_back (std::move (bl));
612- }
612+ lifetime_bounds.emplace_back (new_lifetime (b));
613613
614614 Lifetime nl = new_lifetime (lifetime.get_lifetime ());
615615 LifetimeParam p (std::move (nl), std::move (lifetime_bounds),
@@ -626,12 +626,11 @@ Builder::new_type_param (
626626 {
627627 const TypePathSegment &segment
628628 = (const TypePathSegment &) (*seg.get ());
629- TypePathSegment *s = new TypePathSegment (
629+
630+ segments.emplace_back (new TypePathSegment (
630631 segment.get_ident_segment (),
631632 segment.get_separating_scope_resolution (),
632- segment.get_locus ());
633- std::unique_ptr<TypePathSegment> sg (s);
634- segments.push_back (std::move (sg));
633+ segment.get_locus ()));
635634 }
636635 break ;
637636
@@ -642,11 +641,10 @@ Builder::new_type_param (
642641
643642 GenericArgs args
644643 = new_generic_args (generic.get_generic_args ());
645- TypePathSegmentGeneric *s = new TypePathSegmentGeneric (
644+
645+ segments.emplace_back (new TypePathSegmentGeneric (
646646 generic.get_ident_segment (), false , std::move (args),
647- generic.get_locus ());
648- std::unique_ptr<TypePathSegment> sg (s);
649- segments.push_back (std::move (sg));
647+ generic.get_locus ()));
650648 }
651649 break ;
652650
@@ -664,23 +662,19 @@ Builder::new_type_param (
664662 TypePath p (std::move (segments), path.get_locus (),
665663 path.has_opening_scope_resolution_op ());
666664
667- TraitBound *b = new TraitBound (std::move (p), tb.get_locus (),
668- tb.is_in_parens (),
669- tb.has_opening_question_mark (),
670- std::move (for_lifetimes));
671- std::unique_ptr<TypeParamBound> bound (b);
672- type_param_bounds.push_back (std::move (bound));
665+ type_param_bounds.emplace_back (new TraitBound (
666+ std::move (p), tb.get_locus (), tb.is_in_parens (),
667+ tb.has_opening_question_mark (), std::move (for_lifetimes)));
673668 }
674669 break ;
675670
676671 case TypeParamBound::TypeParamBoundType::LIFETIME:
677672 {
678673 const Lifetime &l = (const Lifetime &) *b.get ();
679674
680- auto bl = new Lifetime (l.get_lifetime_type (),
681- l.get_lifetime_name (), l.get_locus ());
682- std::unique_ptr<TypeParamBound> bound (bl);
683- type_param_bounds.push_back (std::move (bound));
675+ type_param_bounds.emplace_back (
676+ new Lifetime (l.get_lifetime_type (), l.get_lifetime_name (),
677+ l.get_locus ()));
684678 }
685679 break ;
686680 }
@@ -709,18 +703,14 @@ Builder::new_generic_args (GenericArgs &args)
709703 location_t locus = args.get_locus ();
710704
711705 for (const auto &lifetime : args.get_lifetime_args ())
712- {
713- Lifetime l = new_lifetime (lifetime);
714- lifetime_args.push_back (std::move (l));
715- }
706+ lifetime_args.push_back (new_lifetime (lifetime));
716707
717708 for (auto &binding : args.get_binding_args ())
718709 {
719710 Type &t = *binding.get_type_ptr ().get ();
720711 std::unique_ptr<Type> ty = t.reconstruct ();
721- GenericArgsBinding b (binding.get_identifier (), std::move (ty),
722- binding.get_locus ());
723- binding_args.push_back (std::move (b));
712+ binding_args.emplace_back (binding.get_identifier (), std::move (ty),
713+ binding.get_locus ());
724714 }
725715
726716 for (auto &arg : args.get_generic_args ())
0 commit comments