regexps are expensive to create, we ask for packages a lot, cache the re
This commit is contained in:
parent
5735faec03
commit
5903d97966
@ -51,12 +51,18 @@ static PluginLoader *s_pluginLoader = 0;
|
|||||||
class PluginLoaderPrivate
|
class PluginLoaderPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
PluginLoaderPrivate()
|
||||||
|
: packageRE("[^a-zA-Z0-9\\-_]")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static QSet<QString> knownCategories();
|
static QSet<QString> knownCategories();
|
||||||
static QString parentAppConstraint(const QString &parentApp = QString());
|
static QString parentAppConstraint(const QString &parentApp = QString());
|
||||||
|
|
||||||
static QSet<QString> s_customCategories;
|
static QSet<QString> s_customCategories;
|
||||||
QHash<QString, QWeakPointer<PackageStructure> > structures;
|
QHash<QString, QWeakPointer<PackageStructure> > structures;
|
||||||
bool isDefaultLoader;
|
bool isDefaultLoader;
|
||||||
|
QRegExp packageRE;
|
||||||
};
|
};
|
||||||
|
|
||||||
QSet<QString> PluginLoaderPrivate::s_customCategories;
|
QSet<QString> PluginLoaderPrivate::s_customCategories;
|
||||||
@ -423,9 +429,8 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!specialization.isEmpty()) {
|
if (!specialization.isEmpty()) {
|
||||||
QRegExp re("[^a-zA-Z0-9\\-_]");
|
|
||||||
// check that the provided strings are safe to use in a ServiceType query
|
// check that the provided strings are safe to use in a ServiceType query
|
||||||
if (re.indexIn(specialization) == -1 && re.indexIn(packageFormat) == -1) {
|
if (d->packageRE.indexIn(specialization) == -1 && d->packageRE.indexIn(packageFormat) == -1) {
|
||||||
// FIXME: The query below is rather spepcific to script engines. generify if possible
|
// FIXME: The query below is rather spepcific to script engines. generify if possible
|
||||||
const QString component = packageFormat.right(packageFormat.size() - packageFormat.lastIndexOf('/') - 1);
|
const QString component = packageFormat.right(packageFormat.size() - packageFormat.lastIndexOf('/') - 1);
|
||||||
const QString constraint = QString("[X-Plasma-API] == '%1' and " "'%2' in [X-Plasma-ComponentTypes]").arg(specialization, component);
|
const QString constraint = QString("[X-Plasma-API] == '%1' and " "'%2' in [X-Plasma-ComponentTypes]").arg(specialization, component);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user