mirror of
https://github.com/KhronosGroup/SPIRV-Cross.git
synced 2024-11-12 15:10:30 +00:00
Minor optimization of enclose_expression.
This commit is contained in:
parent
f0c50a618d
commit
0d14448b4d
@ -1822,23 +1822,26 @@ string CompilerGLSL::enclose_expression(const string &expr)
|
||||
need_parens = true;
|
||||
}
|
||||
|
||||
uint32_t paren_count = 0;
|
||||
for (auto c : expr)
|
||||
if (!need_parens)
|
||||
{
|
||||
if (c == '(')
|
||||
paren_count++;
|
||||
else if (c == ')')
|
||||
uint32_t paren_count = 0;
|
||||
for (auto c : expr)
|
||||
{
|
||||
assert(paren_count);
|
||||
paren_count--;
|
||||
}
|
||||
else if (c == ' ' && paren_count == 0)
|
||||
{
|
||||
need_parens = true;
|
||||
break;
|
||||
if (c == '(')
|
||||
paren_count++;
|
||||
else if (c == ')')
|
||||
{
|
||||
assert(paren_count);
|
||||
paren_count--;
|
||||
}
|
||||
else if (c == ' ' && paren_count == 0)
|
||||
{
|
||||
need_parens = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(paren_count == 0);
|
||||
}
|
||||
assert(paren_count == 0);
|
||||
|
||||
// If this expression contains any spaces which are not enclosed by parentheses,
|
||||
// we need to enclose it so we can treat the whole string as an expression.
|
||||
|
Loading…
Reference in New Issue
Block a user