[PATCH] D58827: [Sema][NFCI] Don't heap-allocate the various CorrectionCandidateCallback unless we are going to do some typo correction
Bruno Ricci via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 1 06:33:34 PST 2019
riccibruno created this revision.
riccibruno added reviewers: aaron.ballman, rnk, erik.pilkington.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.
The various `CorrectionCandidateCallback`s are currently heap-allocated unconditionally. This was needed because of delayed typo correction. However these allocations represent currently 15.4% of all allocations (number of allocations) when parsing all of Boost (!), mostly because of `ParseCastExpression`, `ParseStatementOrDeclarationAfterAttrtibutes` and `isCXXDeclarationSpecifier`. Note that all of these callback objects are small. Let's not do this.
Instead initially allocate the callback on the stack, and only do a heap allocation if we are going to do some typo correction. Do this by:
1. Adding a `clone` function to each callback, which will do a polymorphic clone of the callback. This clone function is required to be implemented by every callback (of which there is a fair amount). Make sure this is the case by making it pure virtual.
2. Use this `clone` function when we are going to try to correct a typo.
This additionally cut the time of `-fsyntax-only` on all of Boost by 0.5% (not that much, but still something). No functional changes intended.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 59707 bytes
Desc: not available
More information about the cfe-commits