Hi Martin, on 2021/6/23 上午12:14, Martin Sebor wrote: > On 6/21/21 8:35 PM, Kewen.Lin wrote: >> Hi Richi and Martin, >> >>>> >>>> Thanks Richi! One draft (not ready for review) is attached for the further >>>> discussion. It follows the idea of RAII-style cleanup. I noticed that >>>> Martin suggested stepping forward to make tree_predictive_commoning_loop >>>> and its callees into one class (Thanks Martin), since there are not many >>>> this kind of C++-style work functions, I want to double confirm which >>>> option >>>> do you guys prefer? >>>> >>> >>> Such general cleanup is of course desired - Giuliano started some of it >>> within >>> GSoC two years ago in the attempt to thread the compilation process. The >>> cleanup then helps to get rid of global state which of course interferes >>> here >>> (and avoids unnecessary use of TLS vars). >>> >>> So yes, encapsulating global state into a class and making accessors >>> member functions is something that is desired (but a lot of mechanical >>> work). >>> >>> Thanks >>> Richard. >>> >>> I meant that not necessarily as something to include in this patch >>> but as a suggestion for a future improvement. If you'd like to >>> tackle it at any point that would be great of course In any >>> event, thanks for double-checking! >>> >>> The attached patch looks good to me as well (more for the sake of >>> style than anything else, declaring the class copy ctor and copy assignment >>> = delete would > make it clear it's not meant to be >>> copied, although in this case it's unlikely to make a practical >>> difference). >>> >>> Martin. >> >> >> Thanks for your explanation! Sorry for the late response. >> As the way to encapsulate global state into a class and making accessors >> member functions looks more complete, I gave up the RAII draft and >> switched onto this way. >> >> This patch is to encapsulate global states into a class and >> making their accessors as member functions, remove some >> consequent useless clean up code, and do some clean up with >> RAII. > > Nice! > > A further improvement worth considering (if you're so inclined :) > is replacing the pcom_worker vec members with auto_vec (obviating > having to explicitly release them) and for the same reason also > replacing the comp_ptrs bare pointer members with auto_vecs. > There may be other opportunities to do the same in individual > functions (I'd look to get rid of as many calls to functions > like XNEW()/XNEWVEC() and free() use auto_vec instead). > > An unrelated but worthwhile change is to replace the FOR_EACH_ > loops with C++ 11 range loops, analogously to: > https://gcc.gnu.org/pipermail/gcc-patches/2021-June/572315.html > > Finally, the only loosely followed naming convention for member > variables is to start them with the m_ prefix. > > These just suggestions that could be done in a followup, not > something I would consider prerequisite for accepting the patch > as is if I were in a position to make such a decision. >
Many thanks for all the great suggestions! I'll deal with them in a follow up patch. BR, Kewen