cppcheck algorithm suggestions

Dr. David Alan Gilbert dave at treblig.org
Mon Jan 25 15:45:30 UTC 2021


* Lubo?? Lu???k (l.lunak at 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.lunak at collabora.com
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at 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   |_______/


More information about the LibreOffice mailing list