QHash replaces QMap as the sorting of QMap is pure overhead

This commit is contained in:
Aaron Seigo 2011-05-26 19:01:44 +02:00
parent 23ee4d2f31
commit 060ef1757b
18 changed files with 42 additions and 44 deletions

View File

@ -35,8 +35,7 @@ DataEngineService::DataEngineService(DataEngine *engine)
connect(engine, SIGNAL(sourceAdded(QString)), this, SLOT(sourceAdded(QString)));
}
Plasma::ServiceJob* DataEngineService::createJob(const QString& operation,
QMap<QString,QVariant>& parameters)
Plasma::ServiceJob* DataEngineService::createJob(const QString& operation, QHash<QString,QVariant>& parameters)
{
return new GetSource(m_engine, operation, parameters, this);
}

View File

@ -42,15 +42,15 @@ class DataEngineService : public Plasma::Service
protected:
Plasma::ServiceJob* createJob(const QString& operation,
QMap<QString,QVariant>& parameters);
QHash<QString,QVariant>& parameters);
private Q_SLOTS:
void sourceAdded(QString source);
private:
DataEngine *m_engine;
QMap<QString, QStringList> m_peersAlreadyUpdated;
QMap<QString, DataEngine::Data> m_data;
QHash<QString, QStringList> m_peersAlreadyUpdated;
QHash<QString, DataEngine::Data> m_data;
friend class GetSource;
};

View File

@ -33,7 +33,7 @@ namespace Plasma
{
GetSource::GetSource(DataEngine *engine, const QString& operation,
QMap<QString,QVariant>& parameters,
QHash<QString,QVariant>& parameters,
DataEngineService *service)
: ServiceJob(QString("publickey"), operation, parameters, service),
m_engine(engine),

View File

@ -33,7 +33,7 @@ class GetSource : public Plasma::ServiceJob
public:
GetSource(DataEngine *engine, const QString& operation,
QMap<QString,QVariant>& parameters,
QHash<QString,QVariant>& parameters,
DataEngineService *service = 0);
void start();

View File

@ -43,7 +43,7 @@ namespace Plasma
PlasmoidServiceJob::PlasmoidServiceJob(const QString &plasmoidLocation,
const QString &destination,
const QString &operation,
QMap<QString,QVariant>& parameters,
QHash<QString,QVariant>& parameters,
PlasmoidService *service)
: Plasma::ServiceJob(destination, operation, parameters,
static_cast<Plasma::Service*>(service)),
@ -136,8 +136,7 @@ PackageMetadata PlasmoidService::metadata() const
return m_metadata;
}
Plasma::ServiceJob* PlasmoidService::createJob(const QString& operation,
QMap<QString,QVariant>& parameters)
Plasma::ServiceJob* PlasmoidService::createJob(const QString& operation, QHash<QString,QVariant>& parameters)
{
return new PlasmoidServiceJob(m_packagePath, destination(), operation, parameters, this);
}

View File

@ -44,7 +44,7 @@ class PlasmoidServiceJob : public ServiceJob
PlasmoidServiceJob(const QString &plasmoidLocation,
const QString &destination,
const QString &operation,
QMap<QString,QVariant>& parameters,
QHash<QString,QVariant>& parameters,
PlasmoidService *parent = 0);
void start();
@ -67,7 +67,7 @@ class PlasmoidService : public Service, DataEngineConsumer
protected:
Plasma::ServiceJob* createJob(const QString& operation,
QMap<QString,QVariant>& parameters);
QHash<QString,QVariant>& parameters);
private:
QString m_packagePath;

View File

@ -238,7 +238,7 @@ void RemoteService::slotUpdateEnabledOperations()
}
ServiceJob* RemoteService::createJob(const QString& operation,
QMap<QString,QVariant>& parameters)
QHash<QString,QVariant>& parameters)
{
if (!m_ready) {
kDebug() << "Use of this service hasn't checked for the serviceReady signal, which it should.";

View File

@ -53,7 +53,7 @@ class RemoteService : public Plasma::Service
protected:
ServiceJob* createJob(const QString& operation,
QMap<QString,QVariant>& parameters);
QHash<QString,QVariant>& parameters);
void registerOperationsScheme();
private Q_SLOTS:

View File

@ -42,7 +42,7 @@ namespace Plasma
RemoteServiceJob::RemoteServiceJob(KUrl location,
const QString& destination,
const QString& operation,
QMap<QString,QVariant>& parameters,
QHash<QString,QVariant>& parameters,
QByteArray initialToken,
RemoteService* parent)
: ServiceJob(destination, operation, parameters, parent),
@ -121,7 +121,7 @@ void RemoteServiceJob::checkValidity()
d->parameters = m_service->parametersFromDescription(*m_delayedDesc);
} else {
KConfigGroup description = m_service->operationDescription(operationName());
QMapIterator<QString, QVariant> param(parameters());
QHashIterator<QString, QVariant> param(parameters());
while (param.hasNext()) {
param.next();
if (!description.hasKey(param.key())) {

View File

@ -44,7 +44,7 @@ class RemoteServiceJob : public Plasma::ServiceJob
RemoteServiceJob(KUrl location,
const QString& destination,
const QString& operation,
QMap<QString,QVariant>& parameters,
QHash<QString,QVariant>& parameters,
QByteArray initialToken,
RemoteService *parent);
~RemoteServiceJob();

View File

@ -24,7 +24,7 @@
#include "service.h"
#include <QGraphicsWidget>
#include <QMap>
#include <QHash>
#include <QMultiHash>
#include <QWidget>
#include <QSet>
@ -45,7 +45,7 @@ class NullServiceJob : public ServiceJob
{
public:
NullServiceJob(const QString &destination, const QString &operation, QObject *parent)
: ServiceJob(destination, operation, QMap<QString, QVariant>(), parent)
: ServiceJob(destination, operation, QHash<QString, QVariant>(), parent)
{
}
@ -66,7 +66,7 @@ public:
setName("NullService");
}
ServiceJob *createJob(const QString &operation, QMap<QString, QVariant> &)
ServiceJob *createJob(const QString &operation, QHash<QString, QVariant> &)
{
return new NullServiceJob(destination(), operation, this);
}

View File

@ -24,7 +24,7 @@
#include <QString>
#include <QVariant>
#include <QMap>
#include <QHash>
namespace Plasma
{
@ -35,7 +35,7 @@ public:
ServiceJobPrivate(ServiceJob *owner,
const QString &dest,
const QString &op,
const QMap<QString, QVariant> &params);
const QHash<QString, QVariant> &params);
void preventAutoStart();
void autoStart();
@ -43,7 +43,7 @@ public:
ServiceJob *q;
QString destination;
QString operation;
QMap<QString, QVariant> parameters;
QHash<QString, QVariant> parameters;
QVariant result;
Credentials identity;
bool m_allowAutoStart;

View File

@ -47,7 +47,7 @@ static QThreadStorage<RefCountedDatabase *> s_databasePool;
//Storage Job implentation
StorageJob::StorageJob(const QString& destination,
const QString& operation,
const QMap<QString, QVariant>& parameters,
const QHash<QString, QVariant>& parameters,
QObject *parent)
: ServiceJob(destination, operation, parameters, parent),
m_clientName(destination)
@ -81,7 +81,7 @@ QString StorageJob::clientName() const
void StorageJob::start()
{
//FIXME: QHASH
QMap<QString, QVariant> params = parameters();
QHash<QString, QVariant> params = parameters();
QString valueGroup = params["group"].toString();
if (valueGroup.isEmpty()) {
@ -90,13 +90,13 @@ void StorageJob::start()
QWeakPointer<StorageJob> me(this);
if (operationName() == "save") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "save", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "save", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantHash&, params));
} else if (operationName() == "retrieve") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "retrieve", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "retrieve", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantHash&, params));
} else if (operationName() == "delete") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "deleteEntry", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "deleteEntry", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantHash&, params));
} else if (operationName() == "expire") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "expire", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "expire", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantHash&, params));
} else {
setError(true);
setResult(false);
@ -113,7 +113,7 @@ void StorageJob::resultSlot(StorageJob *job, const QVariant &result)
}
}
Plasma::ServiceJob* Storage::createJob(const QString &operation, QMap<QString, QVariant> &parameters)
Plasma::ServiceJob* Storage::createJob(const QString &operation, QHash<QString, QVariant> &parameters)
{
if (m_clientName.isEmpty()) {
return 0;

View File

@ -37,7 +37,7 @@ class StorageJob : public Plasma::ServiceJob
public:
StorageJob(const QString& destination,
const QString& operation,
const QMap<QString, QVariant>& parameters,
const QHash<QString, QVariant>& parameters,
QObject *parent = 0);
~StorageJob();
void setData(const QVariantHash &data);
@ -66,7 +66,7 @@ public:
~Storage();
protected:
Plasma::ServiceJob* createJob(const QString &operation, QMap<QString, QVariant> &parameters);
Plasma::ServiceJob* createJob(const QString &operation, QHash<QString, QVariant> &parameters);
private:
QString m_clientName;

View File

@ -191,9 +191,9 @@ KConfigGroup Service::operationDescription(const QString &operationName)
return params;
}
QMap<QString, QVariant> Service::parametersFromDescription(const KConfigGroup &description)
QHash<QString, QVariant> Service::parametersFromDescription(const KConfigGroup &description)
{
QMap<QString, QVariant> params;
QHash<QString, QVariant> params;
if (!d->config || !description.isValid()) {
return params;
@ -220,7 +220,7 @@ ServiceJob *Service::startOperationCall(const KConfigGroup &description, QObject
if (!op.isEmpty() && rs && !rs->isReady()) {
// if we have an operation, but a non-ready remote service, just let it through
kDebug() << "Remote service is not ready; queueing operation";
QMap<QString, QVariant> params;
QHash<QString, QVariant> params;
job = createJob(op, params);
RemoteServiceJob *rsj = qobject_cast<RemoteServiceJob *>(job);
if (rsj) {
@ -232,7 +232,7 @@ ServiceJob *Service::startOperationCall(const KConfigGroup &description, QObject
if (d->disabledOperations.contains(op)) {
kDebug() << "Operation" << op << "is disabled";
} else {
QMap<QString, QVariant> params = parametersFromDescription(description);
QHash<QString, QVariant> params = parametersFromDescription(description);
job = createJob(op, params);
}
} else {

View File

@ -20,7 +20,7 @@
#ifndef PLASMA_SERVICE_H
#define PLASMA_SERVICE_H
#include <QtCore/QMap>
#include <QtCore/QHash>
#include <QtCore/QObject>
#include <QtCore/QVariant>
@ -227,7 +227,7 @@ public:
* @arg description the configuration values to turn into the parameter map
* @since 4.4
*/
Q_INVOKABLE QMap<QString, QVariant> parametersFromDescription(const KConfigGroup &description);
Q_INVOKABLE QHash<QString, QVariant> parametersFromDescription(const KConfigGroup &description);
Q_SIGNALS:
/**
@ -268,7 +268,7 @@ protected:
* @return a ServiceJob that can be started and monitored by the consumer
*/
virtual ServiceJob *createJob(const QString &operation,
QMap<QString, QVariant> &parameters) = 0;
QHash<QString, QVariant> &parameters) = 0;
/**
* By default this is based on the file in plasma/services/name.operations, but can be

View File

@ -27,7 +27,7 @@ namespace Plasma
{
ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest,
const QString &op, const QMap<QString, QVariant> &params)
const QString &op, const QHash<QString, QVariant> &params)
: q(owner),
destination(dest),
operation(op),
@ -49,7 +49,7 @@ void ServiceJobPrivate::autoStart()
}
ServiceJob::ServiceJob(const QString &destination, const QString &operation,
const QMap<QString, QVariant> &parameters, QObject *parent)
const QHash<QString, QVariant> &parameters, QObject *parent)
: KJob(parent),
d(new ServiceJobPrivate(this, destination, operation, parameters))
{
@ -71,7 +71,7 @@ QString ServiceJob::operationName() const
return d->operation;
}
QMap<QString, QVariant> ServiceJob::parameters() const
QHash<QString, QVariant> ServiceJob::parameters() const
{
return d->parameters;
}

View File

@ -69,7 +69,7 @@ public:
* @arg parent the parent object for this service
*/
ServiceJob(const QString &destination, const QString &operation,
const QMap<QString, QVariant> &parameters, QObject *parent = 0);
const QHash<QString, QVariant> &parameters, QObject *parent = 0);
/**
* Destructor
@ -89,7 +89,7 @@ public:
/**
* @return the parameters for the operation
*/
QMap<QString, QVariant> parameters() const;
QHash<QString, QVariant> parameters() const;
/**
* @return the identity of the caller of this operation