summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-04-20 18:19:33 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-04-20 19:44:31 +0200
commit5e23cf2968b3c08f49b0c34c4aa3d151dbc10f89 (patch)
tree10d754c1ddd5354036e9189b9435a75e7cc183d9
parent85801227a9b27234e6107268aa15d26e103a3f3a (diff)
downloadqt-creator-5e23cf2968b3c08f49b0c34c4aa3d151dbc10f89.tar.gz
eliminate m_filevaluemap by using source tagging
instead of having a second value map per included file, simply tag all values with the project file they are coming from. a lot cleaner and marginally faster.
-rw-r--r--src/shared/proparser/profileevaluator.cpp24
-rw-r--r--src/shared/proparser/proitems.cpp24
-rw-r--r--src/shared/proparser/proitems.h4
3 files changed, 28 insertions, 24 deletions
diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp
index 6cb1ad1ecf..763bf9b58f 100644
--- a/src/shared/proparser/profileevaluator.cpp
+++ b/src/shared/proparser/profileevaluator.cpp
@@ -279,7 +279,6 @@ public:
FunctionDefs m_functionDefs;
ProStringList m_returnValue;
QStack<QHash<ProString, ProStringList> > m_valuemapStack; // VariableName must be us-ascii, the content however can be non-us-ascii.
- QHash<const ProFile*, QHash<ProString, ProStringList> > m_filevaluemap; // Variables per include file
QString m_tmp1, m_tmp2, m_tmp3, m_tmp[2]; // Temporaries for efficient toQString
ProFileOption *m_option;
@@ -514,6 +513,7 @@ ProString ProFileEvaluator::Private::getStr(const ushort *&tokPtr)
{
uint len = *tokPtr++;
ProString ret(m_current.pro->items(), tokPtr - m_current.pro->tokPtr(), len, NoHash);
+ ret.setSource(m_current.pro);
tokPtr += len;
return ret;
}
@@ -1107,7 +1107,6 @@ void ProFileEvaluator::Private::visitProVariable(
// We could make a union of modified and unmodified values,
// but this will break just as much as it fixes, so leave it as is.
replaceInList(&valuesRef(varName), regexp, replace, global, m_tmp2);
- replaceInList(&m_filevaluemap[currentProFile()][varName], regexp, replace, global, m_tmp2);
}
} else {
ProStringList varVal = expandVariableReferences(tokPtr, sizeHint);
@@ -1118,7 +1117,6 @@ void ProFileEvaluator::Private::visitProVariable(
if (!m_skipLevel) {
zipEmpty(&varVal);
m_valuemapStack.top()[varName] = varVal;
- m_filevaluemap[currentProFile()][varName] = varVal;
}
} else {
zipEmpty(&varVal);
@@ -1139,31 +1137,23 @@ void ProFileEvaluator::Private::visitProVariable(
if (!has.contains(s))
v << s;
}
- // These values will not be used for further processing inside
- // the evaluator. Duplicate elimination happens later.
- m_filevaluemap[currentProFile()][varName] += varVal;
}
}
break;
case TokAppendUnique: // *=
- if (!m_skipLevel || m_cumulative) {
+ if (!m_skipLevel || m_cumulative)
insertUnique(&valuesRef(varName), varVal);
- insertUnique(&m_filevaluemap[currentProFile()][varName], varVal);
- }
break;
case TokAppend: // +=
if (!m_skipLevel || m_cumulative) {
zipEmpty(&varVal);
valuesRef(varName) += varVal;
- m_filevaluemap[currentProFile()][varName] += varVal;
}
break;
case TokRemove: // -=
if (!m_cumulative) {
- if (!m_skipLevel) {
+ if (!m_skipLevel)
removeEach(&valuesRef(varName), varVal);
- removeEach(&m_filevaluemap[currentProFile()][varName], varVal);
- }
} else {
// We are stingy with our values, too.
}
@@ -3277,7 +3267,13 @@ QStringList ProFileEvaluator::values(const QString &variableName) const
QStringList ProFileEvaluator::values(const QString &variableName, const ProFile *pro) const
{
// It makes no sense to put any kind of magic into expanding these
- return expandEnvVars(d->m_filevaluemap.value(pro).value(ProString(variableName)));
+ const ProStringList &values = d->m_valuemapStack.at(0).value(ProString(variableName));
+ QStringList ret;
+ ret.reserve(values.size());
+ foreach (const ProString &str, values)
+ if (str.sourceFile() == pro)
+ ret << expandEnvVars(str.toQString());
+ return ret;
}
QStringList ProFileEvaluator::absolutePathValues(
diff --git a/src/shared/proparser/proitems.cpp b/src/shared/proparser/proitems.cpp
index 46f6adbe19..5171db68d0 100644
--- a/src/shared/proparser/proitems.cpp
+++ b/src/shared/proparser/proitems.cpp
@@ -53,55 +53,55 @@ uint ProString::hash(const QChar *p, int n)
}
ProString::ProString() :
- m_offset(0), m_length(0), m_hash(0x80000000)
+ m_offset(0), m_length(0), m_file(0), m_hash(0x80000000)
{
}
ProString::ProString(const ProString &other) :
- m_string(other.m_string), m_offset(other.m_offset), m_length(other.m_length), m_hash(other.m_hash)
+ m_string(other.m_string), m_offset(other.m_offset), m_length(other.m_length), m_file(other.m_file), m_hash(other.m_hash)
{
}
ProString::ProString(const ProString &other, OmitPreHashing) :
- m_string(other.m_string), m_offset(other.m_offset), m_length(other.m_length), m_hash(0x80000000)
+ m_string(other.m_string), m_offset(other.m_offset), m_length(other.m_length), m_file(other.m_file), m_hash(0x80000000)
{
}
ProString::ProString(const QString &str) :
- m_string(str), m_offset(0), m_length(str.length())
+ m_string(str), m_offset(0), m_length(str.length()), m_file(0)
{
updatedHash();
}
ProString::ProString(const QString &str, OmitPreHashing) :
- m_string(str), m_offset(0), m_length(str.length()), m_hash(0x80000000)
+ m_string(str), m_offset(0), m_length(str.length()), m_file(0), m_hash(0x80000000)
{
}
ProString::ProString(const char *str) :
- m_string(QString::fromLatin1(str)), m_offset(0), m_length(qstrlen(str))
+ m_string(QString::fromLatin1(str)), m_offset(0), m_length(qstrlen(str)), m_file(0)
{
updatedHash();
}
ProString::ProString(const char *str, OmitPreHashing) :
- m_string(QString::fromLatin1(str)), m_offset(0), m_length(qstrlen(str)), m_hash(0x80000000)
+ m_string(QString::fromLatin1(str)), m_offset(0), m_length(qstrlen(str)), m_file(0), m_hash(0x80000000)
{
}
ProString::ProString(const QString &str, int offset, int length) :
- m_string(str), m_offset(offset), m_length(length)
+ m_string(str), m_offset(offset), m_length(length), m_file(0)
{
updatedHash();
}
ProString::ProString(const QString &str, int offset, int length, uint hash) :
- m_string(str), m_offset(offset), m_length(length), m_hash(hash)
+ m_string(str), m_offset(offset), m_length(length), m_file(0), m_hash(hash)
{
}
ProString::ProString(const QString &str, int offset, int length, ProStringConstants::OmitPreHashing) :
- m_string(str), m_offset(offset), m_length(length), m_hash(0x80000000)
+ m_string(str), m_offset(offset), m_length(length), m_file(0), m_hash(0x80000000)
{
}
@@ -198,6 +198,8 @@ ProString &ProString::append(const ProString &other, bool *pending)
ptr = prepareAppend(other.m_length);
}
memcpy(ptr, other.m_string.constData() + other.m_offset, other.m_length * 2);
+ if (other.m_file)
+ m_file = other.m_file;
}
if (pending)
*pending = true;
@@ -236,6 +238,8 @@ ProString &ProString::append(const ProStringList &other, bool *pending, bool ski
memcpy(ptr, str.m_string.constData() + str.m_offset, str.m_length * 2);
ptr += str.m_length;
}
+ if (other.last().m_file)
+ m_file = other.last().m_file;
}
if (pending)
*pending = true;
diff --git a/src/shared/proparser/proitems.h b/src/shared/proparser/proitems.h
index 3a33adc154..00778907eb 100644
--- a/src/shared/proparser/proitems.h
+++ b/src/shared/proparser/proitems.h
@@ -57,6 +57,7 @@ enum OmitPreHashing { NoHash };
}
class ProStringList;
+class ProFile;
class ProString {
public:
@@ -70,6 +71,8 @@ public:
ProString(const QString &str, int offset, int length);
ProString(const QString &str, int offset, int length, uint hash);
ProString(const QString &str, int offset, int length, ProStringConstants::OmitPreHashing);
+ void setSource(const ProFile *pro) { m_file = pro; }
+ const ProFile *sourceFile() const { return m_file; }
QString toQString() const;
QString &toQString(QString &tmp) const;
ProString &operator+=(const ProString &other);
@@ -95,6 +98,7 @@ public:
private:
QString m_string;
int m_offset, m_length;
+ const ProFile *m_file;
mutable uint m_hash;
QChar *prepareAppend(int extraLen);
uint updatedHash() const;