cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

LCppC backports: Several optimizations/refactorizations.

Open PKEuS opened this issue 2 years ago • 7 comments

As a follow-up to the discussion in PR4143, I am starting to provide a few fixes/improvements from LCppC to cppcheck.

PKEuS avatar Jun 11 '22 09:06 PKEuS

It's quite a large PR. I would feel happier if split it up. I suggest that we only take the first "43d886bd70e0a8d6b7a59d38ec3f2f88a72ba2a1" to start with. I have a pretty good feeling about that.

danmar avatar Jun 11 '22 10:06 danmar

I feel like these should maybe not be in a single PR but rather two separate ones. I also sometimes pack too much stuff into them but I try to stay topical (I think 🙄).

Also did you profile the container efficiency. I have been profiling a lot and so far and std::list did not come up as something we need to look at.

firewave avatar Aug 20 '22 20:08 firewave

I do not see a point in splitting up pull requests (as pull requests are a pain in the ass). It is not meant to be squashed to a single commit when being merged. The commits inside are topical.

Regarding container efficiency: std::list is under most circumstances less efficient than std::vector. Only if you want to delete or insert elements at random positions, or you want to sort it, std::list can be a better choice. In particular, as std::list is a double-linked list, it comes with a huge memory overhead (2*8 bytes overhead per element, plus overhead to to an enormous amount of memory allocations), and a performance penalty when iterating through it as the elements are not in contiguous memory. Here is a very interesting synthetic benchmark on this topic: https://baptiste-wicht.com/posts/2012/12/cpp-benchmark-vector-list-deque.html

However, there is no measurable impact here as these occurences are no hotspots.

PKEuS avatar Aug 23 '22 20:08 PKEuS

I do not see a point in splitting up pull requests (as pull requests are a pain in the ass). It is not meant to be squashed to a single commit when being merged. The commits inside are topical.

In our repo they are being squashed - so the PR needs to be topical and not the commits.

firewave avatar Aug 23 '22 20:08 firewave

There is no need to do so, iirc github gives you the choice between merging, rebasing and squashing.

PKEuS avatar Aug 23 '22 20:08 PKEuS

well I review it as a whole. I hope you can see the value in making it easy to review the PR.

And if I have a review comment would you update the corresponding commit properly or would you add extra "fix review comment" commits?

danmar avatar Aug 25 '22 07:08 danmar

I would update the corresponding commit.

PKEuS avatar Sep 13 '22 20:09 PKEuS