forked from qt-creator/qt-creator
don't split value list right before expanding variables
the latter will do it anyway. this eradicates the performance penalty from the previous commit at its root.
This commit is contained in:
@@ -229,10 +229,10 @@ public:
|
|||||||
const ProFile *pro) const;
|
const ProFile *pro) const;
|
||||||
QString propertyValue(const QString &val, bool complain = true) const;
|
QString propertyValue(const QString &val, bool complain = true) const;
|
||||||
|
|
||||||
static QStringList split_value_list(const QString &vals, bool do_semicolon = false);
|
static QStringList split_value_list(const QString &vals);
|
||||||
static QStringList split_arg_list(const QString ¶ms);
|
static QStringList split_arg_list(const QString ¶ms);
|
||||||
bool isActiveConfig(const QString &config, bool regex = false);
|
bool isActiveConfig(const QString &config, bool regex = false);
|
||||||
QStringList expandVariableReferences(const QString &value);
|
QStringList expandVariableReferences(const QString &value, bool do_semicolon = false);
|
||||||
void doVariableReplace(QString *str);
|
void doVariableReplace(QString *str);
|
||||||
QStringList evaluateExpandFunction(const QString &function, const QString &arguments);
|
QStringList evaluateExpandFunction(const QString &function, const QString &arguments);
|
||||||
QString format(const char *format) const;
|
QString format(const char *format) const;
|
||||||
@@ -745,7 +745,7 @@ QStringList ProFileEvaluator::Private::split_arg_list(const QString ¶ms)
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ProFileEvaluator::Private::split_value_list(const QString &vals, bool do_semicolon)
|
QStringList ProFileEvaluator::Private::split_value_list(const QString &vals)
|
||||||
{
|
{
|
||||||
QString build;
|
QString build;
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
@@ -757,7 +757,6 @@ QStringList ProFileEvaluator::Private::split_value_list(const QString &vals, boo
|
|||||||
const ushort SINGLEQUOTE = '\'';
|
const ushort SINGLEQUOTE = '\'';
|
||||||
const ushort DOUBLEQUOTE = '"';
|
const ushort DOUBLEQUOTE = '"';
|
||||||
const ushort BACKSLASH = '\\';
|
const ushort BACKSLASH = '\\';
|
||||||
const ushort SEMICOLON = ';';
|
|
||||||
|
|
||||||
ushort unicode;
|
ushort unicode;
|
||||||
const QChar *vals_data = vals.data();
|
const QChar *vals_data = vals.data();
|
||||||
@@ -777,8 +776,7 @@ QStringList ProFileEvaluator::Private::split_value_list(const QString &vals, boo
|
|||||||
++parens;
|
++parens;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parens && quote.isEmpty() && ((do_semicolon && unicode == SEMICOLON) ||
|
if (!parens && quote.isEmpty() && vals_data[x] == SPACE) {
|
||||||
vals_data[x] == SPACE)) {
|
|
||||||
ret << build;
|
ret << build;
|
||||||
build.clear();
|
build.clear();
|
||||||
} else {
|
} else {
|
||||||
@@ -990,9 +988,7 @@ void ProFileEvaluator::Private::visitProVariable(ProVariable *var)
|
|||||||
static const QString deppath(QLatin1String("DEPENDPATH"));
|
static const QString deppath(QLatin1String("DEPENDPATH"));
|
||||||
static const QString incpath(QLatin1String("INCLUDEPATH"));
|
static const QString incpath(QLatin1String("INCLUDEPATH"));
|
||||||
bool doSemicolon = (varName == deppath || varName == incpath);
|
bool doSemicolon = (varName == deppath || varName == incpath);
|
||||||
QStringList varVal;
|
QStringList varVal = expandVariableReferences(var->value(), doSemicolon);
|
||||||
foreach (const QString &arg, split_value_list(var->value(), doSemicolon))
|
|
||||||
varVal += expandVariableReferences(arg);
|
|
||||||
|
|
||||||
switch (var->variableOperator()) {
|
switch (var->variableOperator()) {
|
||||||
default: // ReplaceOperator - cannot happen
|
default: // ReplaceOperator - cannot happen
|
||||||
@@ -1380,7 +1376,8 @@ void ProFileEvaluator::Private::doVariableReplace(QString *str)
|
|||||||
*str = expandVariableReferences(*str).join(ProFileOption::field_sep);
|
*str = expandVariableReferences(*str).join(ProFileOption::field_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ProFileEvaluator::Private::expandVariableReferences(const QString &str)
|
QStringList ProFileEvaluator::Private::expandVariableReferences(
|
||||||
|
const QString &str, bool do_semicolon)
|
||||||
{
|
{
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
// if (ok)
|
// if (ok)
|
||||||
@@ -1400,6 +1397,7 @@ QStringList ProFileEvaluator::Private::expandVariableReferences(const QString &s
|
|||||||
const ushort DOT = '.';
|
const ushort DOT = '.';
|
||||||
const ushort SPACE = ' ';
|
const ushort SPACE = ' ';
|
||||||
const ushort TAB = '\t';
|
const ushort TAB = '\t';
|
||||||
|
const ushort SEMICOLON = ';';
|
||||||
const ushort SINGLEQUOTE = '\'';
|
const ushort SINGLEQUOTE = '\'';
|
||||||
const ushort DOUBLEQUOTE = '"';
|
const ushort DOUBLEQUOTE = '"';
|
||||||
|
|
||||||
@@ -1542,8 +1540,11 @@ QStringList ProFileEvaluator::Private::expandVariableReferences(const QString &s
|
|||||||
unicode = 0;
|
unicode = 0;
|
||||||
if (!(replaced++) && i)
|
if (!(replaced++) && i)
|
||||||
current = str.left(i);
|
current = str.left(i);
|
||||||
} else if (!quote && (unicode == SPACE || unicode == TAB)) {
|
} else if (!quote && ((do_semicolon && unicode == SEMICOLON) ||
|
||||||
|
unicode == SPACE || unicode == TAB)) {
|
||||||
unicode = 0;
|
unicode = 0;
|
||||||
|
if (!(replaced++) && i)
|
||||||
|
current = str.left(i);
|
||||||
if (!current.isEmpty()) {
|
if (!current.isEmpty()) {
|
||||||
ret.append(current);
|
ret.append(current);
|
||||||
current.clear();
|
current.clear();
|
||||||
@@ -1552,10 +1553,12 @@ QStringList ProFileEvaluator::Private::expandVariableReferences(const QString &s
|
|||||||
if (replaced && unicode)
|
if (replaced && unicode)
|
||||||
current.append(QChar(unicode));
|
current.append(QChar(unicode));
|
||||||
}
|
}
|
||||||
if (!replaced)
|
if (!replaced) {
|
||||||
ret = QStringList(str);
|
if (!str.isEmpty())
|
||||||
else if (!current.isEmpty())
|
ret.append(str);
|
||||||
|
} else if (!current.isEmpty()) {
|
||||||
ret.append(current);
|
ret.append(current);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1615,12 +1618,8 @@ bool ProFileEvaluator::Private::isActiveConfig(const QString &config, bool regex
|
|||||||
QList<QStringList> ProFileEvaluator::Private::prepareFunctionArgs(const QString &arguments)
|
QList<QStringList> ProFileEvaluator::Private::prepareFunctionArgs(const QString &arguments)
|
||||||
{
|
{
|
||||||
QList<QStringList> args_list;
|
QList<QStringList> args_list;
|
||||||
foreach (const QString &urArg, split_arg_list(arguments)) {
|
foreach (const QString &urArg, split_arg_list(arguments))
|
||||||
QStringList tmp;
|
args_list << expandVariableReferences(urArg);
|
||||||
foreach (const QString &arg, split_value_list(urArg))
|
|
||||||
tmp += expandVariableReferences(arg);
|
|
||||||
args_list << tmp;
|
|
||||||
}
|
|
||||||
return args_list;
|
return args_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user