forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user