fbde93c64f
this drops a 100k loop of copies from ~2700ms to ~37ms and a 100k loop of copy-n-find from ~3900ms to ~40ms. the cache addition is predicated on the idea that lookups of the same files will be frequent enough to warrant the small amount of extra memory usage for the cache. if that does not hold in practice (though it appears to) then this will not be a gain and in fact be a small net loss for memory footprint the dptr change is predicated on the assumption that copies of Package will be frequent, and so must be low cost. this is known to be true. even if it wasn't, there is no down-side to this change. the upside are significant time and memory savings.
96 lines
2.6 KiB
C++
96 lines
2.6 KiB
C++
/*
|
|
* Copyright © 2009 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU Library General Public License version 2 as
|
|
* published by the Free Software Foundation
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this program; if not, write to the
|
|
* Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef PLASMA_PACKAGE_P_H
|
|
#define PLASMA_PACKAGE_P_H
|
|
|
|
#include "../plasma.h"
|
|
#include "../package.h"
|
|
#include "../service.h"
|
|
|
|
#include <QCryptographicHash>
|
|
#include <QDir>
|
|
#include <QString>
|
|
#include <QSharedData>
|
|
|
|
namespace Plasma
|
|
{
|
|
|
|
class ContentStructure
|
|
{
|
|
public:
|
|
ContentStructure()
|
|
: directory(false),
|
|
required(false)
|
|
{
|
|
}
|
|
|
|
ContentStructure(const ContentStructure &other)
|
|
{
|
|
paths = other.paths;
|
|
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
|
|
name = other.name;
|
|
mimeTypes = other.mimeTypes;
|
|
#endif
|
|
directory = other.directory;
|
|
required = other.required;
|
|
}
|
|
|
|
QString found;
|
|
QStringList paths;
|
|
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
|
|
QString name;
|
|
QStringList mimeTypes;
|
|
#endif
|
|
bool directory : 1;
|
|
bool required : 1;
|
|
};
|
|
|
|
class PackagePrivate : public QSharedData
|
|
{
|
|
public:
|
|
PackagePrivate();
|
|
PackagePrivate(const PackagePrivate &other);
|
|
~PackagePrivate();
|
|
|
|
PackagePrivate &operator=(const PackagePrivate &rhs);
|
|
|
|
void createPackageMetadata(const QString &path);
|
|
void updateHash(const QString &basePath, const QString &subPath, const QDir &dir, QCryptographicHash &hash);
|
|
static bool installPackage(const QString &archivePath, const QString &packageRoot, const QString &servicePrefix);
|
|
static bool uninstallPackage(const QString &packageName, const QString &packageRoot, const QString &servicePrefix);
|
|
|
|
QWeakPointer<PackageStructure> structure;
|
|
QString path;
|
|
QStringList contentsPrefixPaths;
|
|
QString defaultPackageRoot;
|
|
QString servicePrefix;
|
|
QHash<QString, QString> discoveries;
|
|
QHash<QByteArray, ContentStructure> contents;
|
|
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
|
|
QStringList mimeTypes;
|
|
#endif
|
|
KPluginInfo *metadata;
|
|
bool externalPaths : 1;
|
|
bool valid : 1;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|