Re: cppcheck algorithm suggestions
* Lubo?? Lu???k (l.lu...@collabora.com) wrote: > On Saturday 23 of January 2021, Dr. David Alan Gilbert wrote: > > Hi, > > What are peoples feelings for cppcheck's suggestions for stl algorithms? > > In https://gerrit.libreoffice.org/c/core/+/109846 I did a 'any_of' > > and a 'accumulate' that it suggested; the any_of does look better, > > the accumulate seems marginally better. > > To me they both seem as a regression. I find the original code easily > readable, I just look and see, while I need to "decypher" the std algo code. That's fair enough; I think that's especially true of the 'accumulate' one where you still actually have to do the addition and pass a total around. It's a real shame that the algorithm code needs the x.begin(), x.end() that makes it more verbose than I'd have expected. > > Does the project/people have general preferences on whether it's > > worth tackling these suggestions? > > > > I was less sure what to do with the suggestions for 'transform'; > > some of them were replacing very simple loops; another > > was using emplace_back to add the results to the destination and I wasn't > > sure what I'd pass into transform for the equivalent. > > Suggestions from an automated tool are just that, suggestions. IMO common > sense should be a higher priority than blindly following an automated tool. Sure, that's why I asked before plunging in and doing a zillion of them. Dave > -- > Lubo?? Lu??ák > l.lu...@collabora.com > ___ > LibreOffice mailing list > LibreOffice@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/libreoffice -- -Open up your eyes, open up your mind, open up your code --- / Dr. David Alan Gilbert| Running GNU/Linux | Happy \ \dave @ treblig.org | | In Hex / \ _|_ http://www.treblig.org |___/ ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: cppcheck algorithm suggestions
On Saturday 23 of January 2021, Dr. David Alan Gilbert wrote: > Hi, > What are peoples feelings for cppcheck's suggestions for stl algorithms? > In https://gerrit.libreoffice.org/c/core/+/109846 I did a 'any_of' > and a 'accumulate' that it suggested; the any_of does look better, > the accumulate seems marginally better. To me they both seem as a regression. I find the original code easily readable, I just look and see, while I need to "decypher" the std algo code. > Does the project/people have general preferences on whether it's > worth tackling these suggestions? > > I was less sure what to do with the suggestions for 'transform'; > some of them were replacing very simple loops; another > was using emplace_back to add the results to the destination and I wasn't > sure what I'd pass into transform for the equivalent. Suggestions from an automated tool are just that, suggestions. IMO common sense should be a higher priority than blindly following an automated tool. -- Luboš Luňák l.lu...@collabora.com ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: cppcheck algorithm suggestions
Hi Dave, On Sat, Jan 23, 2021 at 09:36:57PM +, "Dr. David Alan Gilbert" wrote: > What are peoples feelings for cppcheck's suggestions for stl algorithms? > In https://gerrit.libreoffice.org/c/core/+/109846 I did a 'any_of' > and a 'accumulate' that it suggested; the any_of does look better, > the accumulate seems marginally better. > > Does the project/people have general preferences on whether it's > worth tackling these suggestions? > > I was less sure what to do with the suggestions for 'transform'; > some of them were replacing very simple loops; another > was using emplace_back to add the results to the destination and I wasn't > sure what I'd pass into transform for the equivalent. I think replacing pre-C++11 code with these is an improvement, but if we already use a range-based for loop, then we don't gain much from one more similar refactor. Regards, Miklos ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
cppcheck algorithm suggestions
Hi, What are peoples feelings for cppcheck's suggestions for stl algorithms? In https://gerrit.libreoffice.org/c/core/+/109846 I did a 'any_of' and a 'accumulate' that it suggested; the any_of does look better, the accumulate seems marginally better. Does the project/people have general preferences on whether it's worth tackling these suggestions? I was less sure what to do with the suggestions for 'transform'; some of them were replacing very simple loops; another was using emplace_back to add the results to the destination and I wasn't sure what I'd pass into transform for the equivalent. Dave -- -Open up your eyes, open up your mind, open up your code --- / Dr. David Alan Gilbert| Running GNU/Linux | Happy \ \dave @ treblig.org | | In Hex / \ _|_ http://www.treblig.org |___/ ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice