@@ -554,12 +554,12 @@ std::unique_ptr<GenericParam>
554
554
Builder::new_lifetime_param (LifetimeParam ¶m)
555
555
{
556
556
Lifetime l = new_lifetime (param.get_lifetime ());
557
+
557
558
std::vector<Lifetime> lifetime_bounds;
559
+ lifetime_bounds.reserve (param.get_lifetime_bounds ().size ());
560
+
558
561
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));
563
563
564
564
auto p = new LifetimeParam (l, std::move (lifetime_bounds),
565
565
param.get_outer_attrs (), param.get_locus ());
@@ -605,11 +605,11 @@ Builder::new_type_param (
605
605
for (const auto &lifetime : tb.get_for_lifetimes ())
606
606
{
607
607
std::vector<Lifetime> lifetime_bounds;
608
+ lifetime_bounds.reserve (
609
+ lifetime.get_lifetime_bounds ().size ());
610
+
608
611
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));
613
613
614
614
Lifetime nl = new_lifetime (lifetime.get_lifetime ());
615
615
LifetimeParam p (std::move (nl), std::move (lifetime_bounds),
@@ -626,12 +626,11 @@ Builder::new_type_param (
626
626
{
627
627
const TypePathSegment &segment
628
628
= (const TypePathSegment &) (*seg.get ());
629
- TypePathSegment *s = new TypePathSegment (
629
+
630
+ segments.emplace_back (new TypePathSegment (
630
631
segment.get_ident_segment (),
631
632
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 ()));
635
634
}
636
635
break ;
637
636
@@ -642,11 +641,10 @@ Builder::new_type_param (
642
641
643
642
GenericArgs args
644
643
= new_generic_args (generic.get_generic_args ());
645
- TypePathSegmentGeneric *s = new TypePathSegmentGeneric (
644
+
645
+ segments.emplace_back (new TypePathSegmentGeneric (
646
646
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 ()));
650
648
}
651
649
break ;
652
650
@@ -664,23 +662,19 @@ Builder::new_type_param (
664
662
TypePath p (std::move (segments), path.get_locus (),
665
663
path.has_opening_scope_resolution_op ());
666
664
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)));
673
668
}
674
669
break ;
675
670
676
671
case TypeParamBound::TypeParamBoundType::LIFETIME:
677
672
{
678
673
const Lifetime &l = (const Lifetime &) *b.get ();
679
674
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 ()));
684
678
}
685
679
break ;
686
680
}
@@ -709,18 +703,14 @@ Builder::new_generic_args (GenericArgs &args)
709
703
location_t locus = args.get_locus ();
710
704
711
705
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));
716
707
717
708
for (auto &binding : args.get_binding_args ())
718
709
{
719
710
Type &t = *binding.get_type_ptr ().get ();
720
711
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 ());
724
714
}
725
715
726
716
for (auto &arg : args.get_generic_args ())
0 commit comments