From 75cc8575b411cb268abccd743ecf55baf1c66a42 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 27 Jul 2012 21:55:51 +0200 Subject: [PATCH] save a memory reallocation for short-lived parse results everything which is not stored in the parser cache is assumed to be disposed of rather soon anyway. this increases peak memory usage per evaluator by a few kilobytes (something in the order of five times the file size). as only manual spec parsing and eval() statemenents in projects use non-cached parsers, the impact is pretty much insignificant. Change-Id: I326f312f4dd98b30b692d219de7ae092b6ad3584 Reviewed-by: Daniel Teske Reviewed-by: Oswald Buddenhagen --- src/shared/proparser/qmakeparser.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shared/proparser/qmakeparser.cpp b/src/shared/proparser/qmakeparser.cpp index 49873b10198..b126983d3a2 100644 --- a/src/shared/proparser/qmakeparser.cpp +++ b/src/shared/proparser/qmakeparser.cpp @@ -169,6 +169,7 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, bool cache) delete pro; pro = 0; } else { + pro->itemsRef()->squeeze(); pro->ref(); } ent->pro = pro; @@ -807,8 +808,8 @@ bool QMakeParser::read(ProFile *pro, const QString &in) } while (m_blockstack.size()) leaveScope(tokPtr); - xprBuff.clear(); - *pro->itemsRef() = QString(tokBuff.constData(), tokPtr - (ushort *)tokBuff.constData()); + tokBuff.resize(tokPtr - (ushort *)tokBuff.constData()); // Reserved capacity stays + *pro->itemsRef() = tokBuff; return true; #undef FLUSH_VALUE_LIST