Hi Adrian, > Le 9 août 2019 à 10:18, Adrian Vogelsgesang <[email protected]> a > écrit : > > Hi Akim, > > I see you fixed the outstanding issue regarding yylac_stack_ being a stack > with complete symbols: > >> There's an issue I had not paid attention to: you made a lac_stack_ >> a fully blown stack of symbols (i.e., type, value and location). I >> believe you only need a stack a states, the rest is useless. > > and replaced it by a std::vector. Thanks for taking care of that! :) > > One minor nitpick: > I think > + if (yylen < lac_size) > + { > + for (size_t i = 0; i < yylen; ++i) > + yylac_stack_.pop_back (); > + yylen = 0; > + } > could now be written as > + if (yylen < lac_size) > + { > + yylac_stack_.resize(lac_size - yylen); > + yylen = 0; > + } > > Didn't test it, though - so maybe I am missing something obvious. > Also, I guess/hope the compiler will optimize that out anyway.
You are right, thanks for catching this. I've installed the following patch. Cheers! commit d7cf3f5b181401f42ba5a8586d12885cfb844639 Author: Akim Demaille <[email protected]> Date: Sun Aug 18 06:54:56 2019 -0500 c++: use resize to shrink a vector Suggested by Adrian Vogelsgesang. https://lists.gnu.org/archive/html/bison-patches/2019-08/msg00009.html * data/skeletons/lalr1.cc (yy_lac_check_): here. diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc index 37c12f7d..cf11fba3 100644 --- a/data/skeletons/lalr1.cc +++ b/data/skeletons/lalr1.cc @@ -1182,8 +1182,7 @@ b4_dollar_popdef])[]dnl size_t lac_size = yylac_stack_.size (); if (yylen < lac_size) { - for (size_t i = 0; i < yylen; ++i) - yylac_stack_.pop_back (); + yylac_stack_.resize (lac_size - yylen); yylen = 0; } else if (lac_size)
