aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2017-10-04 15:08:07 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-10-05 10:13:48 +0000
commit3966a02be1ff953c1b4161ca12e05c27b6abe8bb (patch)
tree78931ff446c754900a80817c152687e2d153d5b4 /src/lib/corelib
parentbe10e08a2fcb0610f12e43571cc8c58b0802da62 (diff)
Use std::vector as container for JSSourceValue::Alternative
QList is an inept container for a class as big as Alternative. This also removes the need for qAsConst in several places. Change-Id: I742c3f9af607eeb7825f8e4eab2e3d040723e543 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/corelib')
-rw-r--r--src/lib/corelib/language/evaluatorscriptclass.cpp2
-rw-r--r--src/lib/corelib/language/itemreaderastvisitor.cpp2
-rw-r--r--src/lib/corelib/language/value.cpp7
-rw-r--r--src/lib/corelib/language/value.h8
4 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp
index 91f9b241a..fcc920366 100644
--- a/src/lib/corelib/language/evaluatorscriptclass.cpp
+++ b/src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -148,7 +148,7 @@ private:
QScriptValue conditionScope;
QScriptValue conditionFileScope;
Item *outerItem = data->item->outerItem();
- for (int i = 0; i < value->alternatives().count(); ++i) {
+ for (size_t i = 0; i < value->alternatives().size(); ++i) {
const JSSourceValue::Alternative *alternative = 0;
alternative = &value->alternatives().at(i);
const Evaluator::FileContextScopes fileCtxScopes
diff --git a/src/lib/corelib/language/itemreaderastvisitor.cpp b/src/lib/corelib/language/itemreaderastvisitor.cpp
index 4bc629c5e..9d77472c2 100644
--- a/src/lib/corelib/language/itemreaderastvisitor.cpp
+++ b/src/lib/corelib/language/itemreaderastvisitor.cpp
@@ -315,7 +315,7 @@ void ItemReaderASTVisitor::inheritItem(Item *dst, const Item *src)
QBS_CHECK(!sv->baseValue());
const JSSourceValuePtr baseValue = std::static_pointer_cast<JSSourceValue>(it.value());
sv->setBaseValue(baseValue);
- for (const JSSourceValue::Alternative &alt : qAsConst(sv->m_alternatives))
+ for (const JSSourceValue::Alternative &alt : sv->m_alternatives)
alt.value->setBaseValue(baseValue);
break;
}
diff --git a/src/lib/corelib/language/value.cpp b/src/lib/corelib/language/value.cpp
index 1b73ccf17..f72cb248c 100644
--- a/src/lib/corelib/language/value.cpp
+++ b/src/lib/corelib/language/value.cpp
@@ -104,8 +104,9 @@ JSSourceValue::JSSourceValue(const JSSourceValue &other) : Value(other)
m_baseValue = other.m_baseValue
? std::static_pointer_cast<JSSourceValue>(other.m_baseValue->clone())
: JSSourceValuePtr();
- for (const Alternative &otherAlt : qAsConst(other.m_alternatives))
- m_alternatives << otherAlt.clone();
+ m_alternatives.reserve(other.m_alternatives.size());
+ for (const Alternative &otherAlt : other.m_alternatives)
+ m_alternatives.push_back(otherAlt.clone());
}
JSSourceValuePtr JSSourceValue::create(bool createdByPropertiesBlock)
@@ -155,7 +156,7 @@ void JSSourceValue::setHasFunctionForm(bool b)
void JSSourceValue::setDefiningItem(Item *item)
{
Value::setDefiningItem(item);
- for (const JSSourceValue::Alternative &a : qAsConst(m_alternatives))
+ for (const JSSourceValue::Alternative &a : m_alternatives)
a.value->setDefiningItem(item);
}
diff --git a/src/lib/corelib/language/value.h b/src/lib/corelib/language/value.h
index 49ca1f51a..6dcefc602 100644
--- a/src/lib/corelib/language/value.h
+++ b/src/lib/corelib/language/value.h
@@ -44,6 +44,8 @@
#include <tools/codelocation.h>
#include <QtCore/qvariant.h>
+#include <vector>
+
namespace qbs {
namespace Internal {
class Item;
@@ -156,8 +158,8 @@ public:
JSSourceValuePtr value;
};
- const QList<Alternative> &alternatives() const { return m_alternatives; }
- void addAlternative(const Alternative &alternative) { m_alternatives.append(alternative); }
+ const std::vector<Alternative> &alternatives() const { return m_alternatives; }
+ void addAlternative(const Alternative &alternative) { m_alternatives.push_back(alternative); }
void setDefiningItem(Item *item);
@@ -168,7 +170,7 @@ private:
FileContextPtr m_file;
Flags m_flags;
JSSourceValuePtr m_baseValue;
- QList<Alternative> m_alternatives;
+ std::vector<Alternative> m_alternatives;
};