Revert "Optimize usage of TemplateSimplifier::simplifyCalculations"
This reverts commit 3044612fe9
.
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:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1097,7 +1097,7 @@ private:
|
||||||
"struct Factorial<4> { enum FacHelper { value = 4 * Factorial<3> :: value } ; } ; "
|
"struct Factorial<4> { enum FacHelper { value = 4 * Factorial<3> :: value } ; } ; "
|
||||||
"struct Factorial<3> { enum FacHelper { value = 3 * Factorial<2> :: value } ; } ; "
|
"struct Factorial<3> { enum FacHelper { value = 3 * Factorial<2> :: value } ; } ; "
|
||||||
"struct Factorial<2> { enum FacHelper { value = 2 * Factorial<1> :: value } ; } ; "
|
"struct Factorial<2> { enum FacHelper { value = 2 * Factorial<1> :: value } ; } ; "
|
||||||
"struct Factorial<1> { enum FacHelper { value = Factorial<0> :: value } ; } ;";
|
"struct Factorial<1> { enum FacHelper { value = Factorial < 0 > :: value } ; } ;";
|
||||||
ASSERT_EQUALS(exp, tok(code));
|
ASSERT_EQUALS(exp, tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue