contains + value -> constFind/find with QHash

parent 87d49e47
......@@ -295,8 +295,9 @@ KoColor KoColor::fromXML(const QDomElement& elt, const QString & bitDepthId, con
QString profileName;
if (elt.tagName() != "sRGB") {
profileName = elt.attribute("space", "");
if (aliases.contains(profileName)) {
profileName = aliases.value(profileName);
const QHash<QString, QString>::ConstIterator it = aliases.find(profileName);
if (it != aliases.end()) {
profileName = it.value();
}
if (!KoColorSpaceRegistry::instance()->profileByName(profileName)) {
profileName.clear();
......
......@@ -101,8 +101,9 @@ void KoColorConversionSystem::insertColorSpace(const KoColorSpaceFactory* csf)
Q_ASSERT(engine);
NodeKey engineKey(engine->id(), engine->id(), engine->id());
Node* engineNode = 0;
if (d->graph.contains(engineKey)) {
engineNode = d->graph[engineKey];
QHash<NodeKey, Node*>::ConstIterator it = d->graph.constFind(engineKey);
if (it != d->graph.constEnd()) {
engineNode = it.value();
} else {
engineNode = insertEngine(engine);
}
......@@ -221,8 +222,9 @@ KoColorConversionSystem::Node* KoColorConversionSystem::nodeFor(const QString& _
KoColorConversionSystem::Node* KoColorConversionSystem::nodeFor(const KoColorConversionSystem::NodeKey& key)
{
if (d->graph.contains(key)) {
return d->graph.value(key);
QHash<NodeKey, Node*>::ConstIterator it = d->graph.constFind(key);
if (it != d->graph.constEnd()) {
return it.value();
} else {
return createNode(key.modelId, key.depthId, key.profileName);
}
......@@ -474,14 +476,15 @@ inline KoColorConversionSystem::Path KoColorConversionSystem::findBestPathImpl2(
}
} else {
// This is an incomplete path. Check if there's a better way to get to its endpoint.
if (node2path.contains(newEndNode)) {
Path p2 = node2path[newEndNode];
Node2PathHash::Iterator it = node2path.find(newEndNode);
if (it != node2path.end()) {
Path &p2 = it.value();
if (pQC.lessWorseThan(newP, p2)) {
node2path[ newEndNode ] = newP;
p2 = newP;
possiblePaths.append(newP);
}
} else {
node2path[ newEndNode ] = newP;
node2path.insert(newEndNode, newP);
possiblePaths.append(newP);
}
}
......
......@@ -341,8 +341,10 @@ KoConvolutionOp* KoColorSpace::convolutionOp() const
const KoCompositeOp * KoColorSpace::compositeOp(const QString & id) const
{
if (d->compositeOps.contains(id))
return d->compositeOps.value(id);
const QHash<QString, KoCompositeOp*>::ConstIterator it = d->compositeOps.constFind(id);
if (it != d->compositeOps.constEnd()) {
return it.value();
}
else {
warnPigment << "Asking for non-existent composite operation " << id << ", returning " << COMPOSITE_OVER;
return d->compositeOps.value(COMPOSITE_OVER);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment