dbus: Use QList::reserve(), reduces reallocations.
Change-Id: I5d60220c4d3014067a45a3d3553f0523c9fc7c74 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
19e63a207f
commit
a4d3af9614
@ -317,7 +317,9 @@ void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **
|
||||
}
|
||||
|
||||
QVariantList args;
|
||||
for (int i = 1; i < types.count(); ++i)
|
||||
const int numTypes = types.count();
|
||||
args.reserve(numTypes - 1);
|
||||
for (int i = 1; i < numTypes; ++i)
|
||||
args << QVariant(types.at(i), argv[i]);
|
||||
|
||||
// now emit the signal with all the information
|
||||
|
@ -952,14 +952,19 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
|
||||
}
|
||||
|
||||
// output arguments
|
||||
const int numMetaTypes = metaTypes.count();
|
||||
QVariantList outputArgs;
|
||||
void *null = 0;
|
||||
if (metaTypes[0] != QMetaType::Void && metaTypes[0] != QMetaType::UnknownType) {
|
||||
outputArgs.reserve(numMetaTypes - i + 1);
|
||||
QVariant arg(metaTypes[0], null);
|
||||
outputArgs.append( arg );
|
||||
params[0] = const_cast<void*>(outputArgs.at( outputArgs.count() - 1 ).constData());
|
||||
} else {
|
||||
outputArgs.reserve(numMetaTypes - i);
|
||||
}
|
||||
for ( ; i < metaTypes.count(); ++i) {
|
||||
|
||||
for ( ; i < numMetaTypes; ++i) {
|
||||
QVariant arg(metaTypes[i], null);
|
||||
outputArgs.append( arg );
|
||||
params.append(const_cast<void*>(outputArgs.at( outputArgs.count() - 1 ).constData()));
|
||||
|
@ -278,6 +278,7 @@ int QDBusInterfacePrivate::metacall(QMetaObject::Call c, int id, void **argv)
|
||||
|
||||
// we will assume that the input arguments were passed correctly
|
||||
QVariantList args;
|
||||
args.reserve(inputTypesCount);
|
||||
int i = 1;
|
||||
for ( ; i <= inputTypesCount; ++i)
|
||||
args << QVariant(inputTypes[i], argv[i]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user