This is a result of this thread.
Brief overview and considerations.
std::shared_ptr<std::function>to avoid copy in
GetCommandByExactName()calls. Now care should be taken not to change what
GetCommandByExactName()returns, also commands'
const, i.e. not change inner state because now it's preserved between calls. I have not found any problems but additional review is still required.
std::shared_ptr<cmListFileFunctionImpl>. It avoids a lot of copy operations especially in
FunctionBlockers. Same as above, if someone really needs copy, now it should be done explicitly. I just created type-alias and changed all places to use
opeator->(). Also, it might be better to leave
cmListFileFunctionas it was, create
cmListFileFunctionPtralias and use it everywhere instead of
3rd and 4th commits optimize obviously useless copy operations that were top consumers in heaptrack report when I've fixed previous ones. Here's a benchmark of different join methods.
Also, consider making
I can't see any reason why it should be a
std::map, their order is not used anywhere.
I also made a benchmark for it.
You can see that querying a
std::map is faster only for a very small(<10) set. Currently,
CMake has ~111 built-in commands and even empty run results in 70+ scripted commands.
If it's approved I can add it to this MR as well.