Fix #11886 performance regression (hang) in 2.12dev#5355
Merged
chrchr-github merged 4 commits intocppcheck-opensource:mainfrom Aug 22, 2023
Merged
Fix #11886 performance regression (hang) in 2.12dev#5355chrchr-github merged 4 commits intocppcheck-opensource:mainfrom
chrchr-github merged 4 commits intocppcheck-opensource:mainfrom
Conversation
danmar
reviewed
Aug 22, 2023
| // 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('<'); |
Collaborator
There was a problem hiding this comment.
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.
| const auto pos = thisName.find('<'); | ||
| if (pos == std::string::npos) | ||
| return false; | ||
| const auto posBase = baseName.find('<'); |
Collaborator
There was a problem hiding this comment.
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.
danmar
approved these changes
Aug 22, 2023
Collaborator
danmar
left a comment
There was a problem hiding this comment.
if you consider my comments and do what you feel is best then feel free to merge.. my suggestions are not mandatory changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Or maybe we should just limit the recursion depth.