forked from qt-creator/qt-creator
cplusplus: PPToken
- introduce move constructor
profiling qt-creator on my codebase i saw quite a few instances where reference counting of `QByteArray` showed up in `Preprocessor::handleFunctionLikeMacro` (hundreds of milliseconds of CPU time when profiling for a few seconds). using move semantics we can avoid this source of reference counting. Change-Id: I19a88a0501064f53d8095f7377bf901e462d25a0 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -109,6 +109,10 @@ public:
|
|||||||
: m_src(src)
|
: m_src(src)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
PPToken(QByteArray &&src)
|
||||||
|
: m_src(std::move(src))
|
||||||
|
{}
|
||||||
|
|
||||||
void setSource(const QByteArray &src)
|
void setSource(const QByteArray &src)
|
||||||
{ m_src = src; }
|
{ m_src = src; }
|
||||||
|
|
||||||
|
@@ -1219,12 +1219,12 @@ bool Preprocessor::handleFunctionLikeMacro(const Macro *macro,
|
|||||||
// No formal macro parameter for this identifier in the body.
|
// No formal macro parameter for this identifier in the body.
|
||||||
bodyTk.f.generated = true;
|
bodyTk.f.generated = true;
|
||||||
bodyTk.lineno = baseLine;
|
bodyTk.lineno = baseLine;
|
||||||
expanded.push_back(bodyTk);
|
expanded.push_back(std::move(bodyTk));
|
||||||
}
|
}
|
||||||
} else if (bodyTk.isNot(T_POUND) && bodyTk.isNot(T_POUND_POUND)) {
|
} else if (bodyTk.isNot(T_POUND) && bodyTk.isNot(T_POUND_POUND)) {
|
||||||
bodyTk.f.generated = true;
|
bodyTk.f.generated = true;
|
||||||
bodyTk.lineno = baseLine;
|
bodyTk.lineno = baseLine;
|
||||||
expanded.push_back(bodyTk);
|
expanded.push_back(std::move(bodyTk));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i > 1 && body[int(i) - 1].is(T_POUND_POUND)) {
|
if (i > 1 && body[int(i) - 1].is(T_POUND_POUND)) {
|
||||||
|
Reference in New Issue
Block a user