Minor optimization of enclose_expression.
This commit is contained in:
Родитель
f0c50a618d
Коммит
0d14448b4d
|
@ -1822,23 +1822,26 @@ string CompilerGLSL::enclose_expression(const string &expr)
|
||||||
need_parens = true;
|
need_parens = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t paren_count = 0;
|
if (!need_parens)
|
||||||
for (auto c : expr)
|
|
||||||
{
|
{
|
||||||
if (c == '(')
|
uint32_t paren_count = 0;
|
||||||
paren_count++;
|
for (auto c : expr)
|
||||||
else if (c == ')')
|
|
||||||
{
|
{
|
||||||
assert(paren_count);
|
if (c == '(')
|
||||||
paren_count--;
|
paren_count++;
|
||||||
}
|
else if (c == ')')
|
||||||
else if (c == ' ' && paren_count == 0)
|
{
|
||||||
{
|
assert(paren_count);
|
||||||
need_parens = true;
|
paren_count--;
|
||||||
break;
|
}
|
||||||
|
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,
|
// 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.
|
// we need to enclose it so we can treat the whole string as an expression.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче