[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: master: C++: restore copy-constructor for stack_symbol_type

From: Akim Demaille
Subject: FYI: master: C++: restore copy-constructor for stack_symbol_type
Date: Sat, 25 Aug 2018 11:15:10 +0200

While checking the performances of my ongoing work for move-semantics,
I noticed a performance regression compared to 3.0.5, due to a commit that I
appear to have not posted, that removed a ‘useless' copy-ctor.

commit 10082ac068b9895c0ace2af5f7bb296dc68b9862
Author: Akim Demaille <address@hidden>
Date:   Sat Aug 25 10:57:38 2018 +0200

    "C++: restore copy-constructor for stack_symbol_type
    Benchmarks show that it is more efficient to keep this copy
    constructor, rather than forcing the use of the default constructor
    and then assignment.
    This reverts commit 7ab25ad0208d00f509613e1e151aa3043cf2862f.

diff --git a/data/ b/data/
index eef8176b..95bc61d9 100644
--- a/data/
+++ b/data/
@@ -314,6 +314,8 @@ b4_location_define])])[
       typedef basic_symbol<by_state> super_type;
       /// Construct an empty symbol.
       stack_symbol_type ();
+      /// Copy construct (for efficiency).
+      stack_symbol_type (const stack_symbol_type& that);
       /// Steal the contents from \a sym to build this.
       stack_symbol_type (state_type s, symbol_type& sym);
       /// Assignment, needed by push_back.
@@ -582,6 +584,14 @@ m4_if(b4_prefix, [yy], [],
   ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
+  ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const 
stack_symbol_type& that)
+    : super_type (that.state]b4_locations_if([, that.location])[)
+  {
+    ]b4_variant_if([b4_symbol_variant([that.type_get ()],
+                                      [value], [copy], [that.value])],
+                   [[value = that.value;]])[
+  }
   ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, 
symbol_type& that)
     : super_type (s]b4_variant_if([], [, that.value])[]b4_locations_if([, 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]