summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorSérgio Martins <sergio.martins@kdab.com>2016-01-16 00:24:54 +0000
committerSérgio Martins <iamsergio@gmail.com>2016-02-07 16:50:26 +0000
commit01859cc12126b7205f5b54d383a9aa88db756f21 (patch)
tree89ea0594e2d6e86bc1e0e271d9bf4215a387b28e /src/tools
parentaf499fd7eb4026088ea1ed83a976866ab930dd79 (diff)
downloadqtbase-01859cc12126b7205f5b54d383a9aa88db756f21.tar.gz
Reduce allocations by using reserve()
Change-Id: If34fa53402985f6b3c5e7217bce4a1177af835b6 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp1
-rw-r--r--src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp9
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp4
3 files changed, 10 insertions, 4 deletions
diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
index 51e6b4af4d..10cc6b9929 100644
--- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
+++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
@@ -396,6 +396,7 @@ static void parseCmdLine(QStringList &arguments)
int main(int argc, char **argv)
{
QStringList args;
+ args.reserve(argc - 1);
for (int n = 1; n < argc; ++n)
args.append(QString::fromLocal8Bit(argv[n]));
parseCmdLine(args);
diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp
index 84d82db9a7..7361fa2230 100644
--- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp
+++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp
@@ -389,7 +389,10 @@ static QStringList makeArgNames(const QDBusIntrospection::Arguments &inputArgs,
QDBusIntrospection::Arguments())
{
QStringList retval;
- for (int i = 0; i < inputArgs.count(); ++i) {
+ const int numInputArgs = inputArgs.count();
+ const int numOutputArgs = outputArgs.count();
+ retval.reserve(numInputArgs + numOutputArgs);
+ for (int i = 0; i < numInputArgs; ++i) {
const QDBusIntrospection::Argument &arg = inputArgs.at(i);
QString name = arg.name;
if (name.isEmpty())
@@ -400,7 +403,7 @@ static QStringList makeArgNames(const QDBusIntrospection::Arguments &inputArgs,
name += QLatin1String("_");
retval << name;
}
- for (int i = 0; i < outputArgs.count(); ++i) {
+ for (int i = 0; i < numOutputArgs; ++i) {
const QDBusIntrospection::Argument &arg = outputArgs.at(i);
QString name = arg.name;
if (name.isEmpty())
@@ -1145,7 +1148,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte
int main(int argc, char **argv)
{
QStringList arguments;
-
+ arguments.reserve(argc);
for (int i = 0; i < argc; ++i) {
arguments.append(QString::fromLocal8Bit(argv[i]));
}
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index b02e2dc0ed..9c2d7cbc2c 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -2200,8 +2200,10 @@ QList<WriteInitialization::Item *> WriteInitialization::initializeTreeWidgetItem
{
// items
QList<Item *> items;
+ const int numDomItems = domItems.size();
+ items.reserve(numDomItems);
- for (int i = 0; i < domItems.size(); ++i) {
+ for (int i = 0; i < numDomItems; ++i) {
const DomItem *domItem = domItems.at(i);
Item *item = new Item(QLatin1String("QTreeWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);