Commit 1be08948 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Merge pull request #206 from groleo/master

removeRedundantWhiteSpace micro-optimization
parents 8eca4c66 d4601735
...@@ -1667,10 +1667,11 @@ QCString removeRedundantWhiteSpace(const QCString &s) ...@@ -1667,10 +1667,11 @@ QCString removeRedundantWhiteSpace(const QCString &s)
uint l=s.length(); uint l=s.length();
uint csp=0; uint csp=0;
uint vsp=0; uint vsp=0;
char c;
for (i=0;i<l;i++) for (i=0;i<l;i++)
{ {
nextChar: nextChar:
char c=s.at(i); c=s.at(i);
// search for "const" // search for "const"
if (csp<6 && c==constScope[csp] && // character matches substring "const" if (csp<6 && c==constScope[csp] && // character matches substring "const"
...@@ -1705,7 +1706,7 @@ nextChar: ...@@ -1705,7 +1706,7 @@ nextChar:
if (cc=='\\') // escaped character if (cc=='\\') // escaped character
{ {
growBuf.addChar(s.at(i+1)); growBuf.addChar(s.at(i+1));
i+=2; i+=2;
} }
else if (cc=='"') // end of string else if (cc=='"') // end of string
{ i++; goto nextChar; } { i++; goto nextChar; }
...@@ -1737,14 +1738,16 @@ nextChar: ...@@ -1737,14 +1738,16 @@ nextChar:
growBuf.addChar(','); growBuf.addChar(',');
growBuf.addChar(' '); growBuf.addChar(' ');
} }
else if (i>0 && else if (i>0 &&
((isId(s.at(i)) && s.at(i-1)==')') || (
(s.at(i)=='\'' && s.at(i-1)==' ') (s.at(i-1)==')' && isId(c))
||
(c=='\'' && s.at(i-1)==' ')
) )
) )
{ {
growBuf.addChar(' '); growBuf.addChar(' ');
growBuf.addChar(s.at(i)); growBuf.addChar(c);
} }
else if (c=='t' && csp==5 /*&& (i<5 || !isId(s.at(i-5)))*/ && else if (c=='t' && csp==5 /*&& (i<5 || !isId(s.at(i-5)))*/ &&
!(isId(s.at(i+1)) /*|| s.at(i+1)==' '*/ || !(isId(s.at(i+1)) /*|| s.at(i+1)==' '*/ ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment