moc: don't use QByteArrayLiteral

The byte array literals are only used to append them to another
QByteArray, so they offer only the static size calculation as a
benefit.

However, there are several drawbacks:
- QByteArrayLiteral data cannot be shared the way string literals
  can be, not even within a single TU, and they add a few ints
  for the QByteArrayData header which cannot reside in BSS, but
  need to be stored in DATA.
- QByteArrayLiteral *does* allocate when the compiler doesn't
  support C++11 lambdas.
- QByteArrayLiteral, when not using RVO, litters the code with
  QByteArray dtor calls, which are not inline, and thus can't
  be optimized away.

In particular, when used like this, they do not prevent any
memory allocation (in fact, they might add some, absent lambdas).

So, just append (C) string literals.

Change-Id: Iee5dba8dd970c5cc6df116afc1f8709a62356b06
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2014-10-08 10:05:06 +02:00
parent 4a2cf9ca41
commit 05663e29d0

View File

@ -639,29 +639,29 @@ void Generator::generateFunctions(const QList<FunctionDef>& list, const char *fu
unsigned char flags = type;
if (f.access == FunctionDef::Private) {
flags |= AccessPrivate;
comment.append(QByteArrayLiteral("Private"));
comment.append("Private");
} else if (f.access == FunctionDef::Public) {
flags |= AccessPublic;
comment.append(QByteArrayLiteral("Public"));
comment.append("Public");
} else if (f.access == FunctionDef::Protected) {
flags |= AccessProtected;
comment.append(QByteArrayLiteral("Protected"));
comment.append("Protected");
}
if (f.isCompat) {
flags |= MethodCompatibility;
comment.append(QByteArrayLiteral(" | MethodCompatibility"));
comment.append(" | MethodCompatibility");
}
if (f.wasCloned) {
flags |= MethodCloned;
comment.append(QByteArrayLiteral(" | MethodCloned"));
comment.append(" | MethodCloned");
}
if (f.isScriptable) {
flags |= MethodScriptable;
comment.append(QByteArrayLiteral(" | isScriptable"));
comment.append(" | isScriptable");
}
if (f.revision > 0) {
flags |= MethodRevisioned;
comment.append(QByteArrayLiteral(" | MethodRevisioned"));
comment.append(" | MethodRevisioned");
}
int argc = f.arguments.count();