Skip to content

smallvector.h: bake reserve() into the non-boost SmallVector implementation#4385

Merged
danmar merged 1 commit intocppcheck-opensource:mainfrom
firewave:smallvector-x
Aug 20, 2022
Merged

smallvector.h: bake reserve() into the non-boost SmallVector implementation#4385
danmar merged 1 commit intocppcheck-opensource:mainfrom
firewave:smallvector-x

Conversation

@firewave
Copy link
Copy Markdown
Collaborator

This changes bakes the reserve() call into the non-boost implementation SmallVector construction as it would cause a performance regression with the boost::small_vector implementation (see #3919).

I tested the build with Clang, GCC, MinGW and Visual Studio.

Replacing the std::vector + resreve() appraoch with SmallVector in visitAstNodes() will now yield the same performance when using Clang.
In case of GCC the code actually gets faster since (according to valgrind) it was previously using std::vector<>::reserve(unsigned long) whereas it now uses operator new(unsigned long) just like Clang does. Possibly another issue to report upstream.

Clang 14 2,481,264,505 -> 2,481,270,375
GCC 12 2,388,141,113 -> 2,359,483,453

This patch does not replace the usage yet - that still requires a few more tests and is handled via #3919.

@danmar danmar merged commit 2afd5f8 into cppcheck-opensource:main Aug 20, 2022
@firewave firewave deleted the smallvector-x branch August 20, 2022 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants