Revert "Optimize usage of TemplateSimplifier::simplifyCalculations"
This reverts commit 3044612fe9b13fa6e3c9c190dd964c5c8fe237f0. I got a report about a significant slowdown for a code.
This commit is contained in:
parent
a3f1d28fa5
commit
98e3f373e9
@ -1241,10 +1241,10 @@ bool TemplateSimplifier::simplifyNumericCalculations(Token *tok)
|
|||||||
|
|
||||||
// TODO: This is not the correct class for simplifyCalculations(), so it
|
// TODO: This is not the correct class for simplifyCalculations(), so it
|
||||||
// should be moved away.
|
// should be moved away.
|
||||||
bool TemplateSimplifier::simplifyCalculations(Token *start, const Token * const end)
|
bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
|
||||||
{
|
{
|
||||||
bool ret = false, goback = false;
|
bool ret = false, goback = false;
|
||||||
for (Token *tok = start; tok != end; tok = tok->next()) {
|
for (Token *tok = _tokens; tok; tok = tok->next()) {
|
||||||
if (goback) {
|
if (goback) {
|
||||||
tok = tok->previous();
|
tok = tok->previous();
|
||||||
goback = false;
|
goback = false;
|
||||||
@ -1527,6 +1527,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
|
|||||||
for (std::list<TokenAndName>::const_iterator iter2 = templateInstantiations.begin(); iter2 != templateInstantiations.end(); ++iter2) {
|
for (std::list<TokenAndName>::const_iterator iter2 = templateInstantiations.begin(); iter2 != templateInstantiations.end(); ++iter2) {
|
||||||
if (numberOfTemplateInstantiations != templateInstantiations.size()) {
|
if (numberOfTemplateInstantiations != templateInstantiations.size()) {
|
||||||
numberOfTemplateInstantiations = templateInstantiations.size();
|
numberOfTemplateInstantiations = templateInstantiations.size();
|
||||||
|
simplifyCalculations(tokenlist.front());
|
||||||
++recursiveCount;
|
++recursiveCount;
|
||||||
if (recursiveCount > 100) {
|
if (recursiveCount > 100) {
|
||||||
// bail out..
|
// bail out..
|
||||||
@ -1541,8 +1542,6 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
|
|||||||
if (iter2->name != templateDeclaration.name)
|
if (iter2->name != templateDeclaration.name)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
simplifyCalculations(iter2->token->next(), iter2->token->linkAt(1));
|
|
||||||
|
|
||||||
if (!matchSpecialization(tok->tokAt(namepos), iter2->token, specializations))
|
if (!matchSpecialization(tok->tokAt(namepos), iter2->token, specializations))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -224,12 +224,11 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Simplify constant calculations such as "1+2" => "3".
|
* Simplify constant calculations such as "1+2" => "3".
|
||||||
* This also performs simple cleanup of parentheses etc.
|
* This also performs simple cleanup of parentheses etc.
|
||||||
* @param start start token
|
* @param _tokens start token
|
||||||
* @param end end token
|
|
||||||
* @return true if modifications to token-list are done.
|
* @return true if modifications to token-list are done.
|
||||||
* false if no modifications are done.
|
* false if no modifications are done.
|
||||||
*/
|
*/
|
||||||
static bool simplifyCalculations(Token *start, const Token *end = nullptr);
|
static bool simplifyCalculations(Token *_tokens);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user