Skip to content

Fix #11886 performance regression (hang) in 2.12dev#5355

Merged
chrchr-github merged 4 commits intocppcheck-opensource:mainfrom
chrchr-github:chr_Fix11886
Aug 22, 2023
Merged

Fix #11886 performance regression (hang) in 2.12dev#5355
chrchr-github merged 4 commits intocppcheck-opensource:mainfrom
chrchr-github:chr_Fix11886

Conversation

@chrchr-github
Copy link
Copy Markdown
Collaborator

Or maybe we should just limit the recursion depth.

Comment thread lib/symboldatabase.cpp
// prevent recursion if base is the same except for different template parameters
static bool isDerivedFromItself(const std::string& thisName, const std::string& baseName)
{
const auto pos = thisName.find('<');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that if this a hot path we could add something like this first to get a quick bailout:

if (thisName.back() != '>')
    return false;

Well if it's not hot then it's just extra code so feel free to skip that.

Comment thread lib/symboldatabase.cpp Outdated
const auto pos = thisName.find('<');
if (pos == std::string::npos)
return false;
const auto posBase = baseName.find('<');
Copy link
Copy Markdown
Collaborator

@danmar danmar Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion.. but we don't really need posBase how about:

return pos < baseName.size() && thisName.compare(0, pos + 1, baseName) == 0;

I am not sure if the pos < baseName.size() && is needed though.

Copy link
Copy Markdown
Collaborator

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you consider my comments and do what you feel is best then feel free to merge.. my suggestions are not mandatory changes.

@chrchr-github chrchr-github merged commit 6ffe08c into cppcheck-opensource:main Aug 22, 2023
@chrchr-github chrchr-github deleted the chr_Fix11886 branch August 22, 2023 19:01
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