qmake: fix excessive detaching of raw data

... in $$basename(), $$dirname(), and contains(). the latter case is
marginal, as it only applies to mutuals which are regexes, which i don't
remember ever seeing used.

QRegExp saves a copy of the matched string, so it's necessary to
alternate between two temporaries to avoid detaching. we already
did that in most places.

Change-Id: I97b8294585c17c76d1756f83971f42cb88353af0
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Oswald Buddenhagen 2017-08-11 13:24:43 +02:00 committed by Tony Sarajärvi
parent eb0ba90b0a
commit 5131bb9bed

View File

@ -585,8 +585,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
if (regexp) {
QRegExp sepRx(sep);
for (const ProString &str : strings) {
const QString &rstr = str.toQString(m_tmp1).section(sepRx, beg, end);
ret << (rstr.isSharedWith(m_tmp1) ? str : ProString(rstr).setSource(str));
const QString &rstr = str.toQString(m_tmp[m_toggle ^= 1]).section(sepRx, beg, end);
ret << (rstr.isSharedWith(m_tmp[m_toggle]) ? str : ProString(rstr).setSource(str));
}
} else {
for (const ProString &str : strings) {
@ -1471,7 +1471,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
for (int mut = 0; mut < mutuals.count(); mut++) {
if (val == mutuals[mut].trimmed()) {
return returnBool((!regx.isEmpty()
&& regx.exactMatch(val.toQString(m_tmp2)))
&& regx.exactMatch(val.toQString(m_tmp[m_toggle ^= 1])))
|| val == qry);
}
}