summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2017-09-18 15:01:09 +0200
committerChristian Stromme <christian.stromme@qt.io>2017-11-14 11:57:06 +0000
commit57dc68b56858a1f9892319e8789169b2953c4c6e (patch)
tree759b8316835b0704595b79ef0a8adabbc42c0f4c
parentacdf4433b7b8e022b3962cf05188d9da2513b31c (diff)
Remove unnecessary list searches
Several times we would check if a job was inserted into the job list even though we already knew if it was inserted or not. Change-Id: I3501ffce2e1493401d83ccebec47e3eeaa0b7f9b Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/animation/backend/handler.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/animation/backend/handler.cpp b/src/animation/backend/handler.cpp
index 071343791..fd8e0916d 100644
--- a/src/animation/backend/handler.cpp
+++ b/src/animation/backend/handler.cpp
@@ -182,7 +182,8 @@ QVector<Qt3DCore::QAspectJobPtr> Handler::jobsToExecute(qint64 time)
// If there are any dirty animation clips that need loading,
// queue up a job for them
- if (!m_dirtyAnimationClips.isEmpty()) {
+ const bool hasLoadAnimationClipJob = !m_dirtyAnimationClips.isEmpty();
+ if (hasLoadAnimationClipJob) {
qCDebug(HandlerLogic) << "Added LoadAnimationClipJob";
m_loadAnimationClipJob->addDirtyAnimationClips(m_dirtyAnimationClips);
jobs.push_back(m_loadAnimationClipJob);
@@ -192,19 +193,22 @@ QVector<Qt3DCore::QAspectJobPtr> Handler::jobsToExecute(qint64 time)
// If there are dirty clip animators, find the set that are able to
// run. I.e. are marked as running and have animation clips and
// channel mappings
- if (!m_dirtyClipAnimators.isEmpty()) {
+
+ const bool hasFindRunningClipAnimatorsJob = !m_dirtyClipAnimators.isEmpty();
+ if (hasFindRunningClipAnimatorsJob) {
qCDebug(HandlerLogic) << "Added FindRunningClipAnimatorsJob";
m_findRunningClipAnimatorsJob->removeDependency(QWeakPointer<Qt3DCore::QAspectJob>());
cleanupHandleList(&m_dirtyClipAnimators);
m_findRunningClipAnimatorsJob->setDirtyClipAnimators(m_dirtyClipAnimators);
jobs.push_back(m_findRunningClipAnimatorsJob);
- if (jobs.contains(m_loadAnimationClipJob))
+ if (hasLoadAnimationClipJob)
m_findRunningClipAnimatorsJob->addDependency(m_loadAnimationClipJob);
m_dirtyClipAnimators.clear();
}
// Rebuild blending trees if a blend tree is dirty
- if (!m_dirtyBlendedAnimators.isEmpty()) {
+ const bool hasBuildBlendTreesJob = !m_dirtyBlendedAnimators.isEmpty();
+ if (hasBuildBlendTreesJob) {
const QVector<HBlendedClipAnimator> dirtyBlendedAnimators = std::move(m_dirtyBlendedAnimators);
m_buildBlendTreesJob->setBlendedClipAnimators(dirtyBlendedAnimators);
jobs.push_back(m_buildBlendTreesJob);
@@ -233,9 +237,9 @@ QVector<Qt3DCore::QAspectJobPtr> Handler::jobsToExecute(qint64 time)
for (int i = 0; i < newSize; ++i) {
m_evaluateClipAnimatorJobs[i]->setClipAnimator(m_runningClipAnimators[i]);
m_evaluateClipAnimatorJobs[i]->removeDependency(QWeakPointer<Qt3DCore::QAspectJob>());
- if (jobs.contains(m_loadAnimationClipJob))
+ if (hasLoadAnimationClipJob)
m_evaluateClipAnimatorJobs[i]->addDependency(m_loadAnimationClipJob);
- if (jobs.contains(m_findRunningClipAnimatorsJob))
+ if (hasFindRunningClipAnimatorsJob)
m_evaluateClipAnimatorJobs[i]->addDependency(m_findRunningClipAnimatorsJob);
jobs.push_back(m_evaluateClipAnimatorJobs[i]);
}
@@ -259,9 +263,9 @@ QVector<Qt3DCore::QAspectJobPtr> Handler::jobsToExecute(qint64 time)
for (int i = 0; i < newSize; ++i) {
m_evaluateBlendClipAnimatorJobs[i]->setBlendClipAnimator(m_runningBlendedClipAnimators[i]);
m_evaluateBlendClipAnimatorJobs[i]->removeDependency(QWeakPointer<Qt3DCore::QAspectJob>());
- if (jobs.contains(m_loadAnimationClipJob))
+ if (hasLoadAnimationClipJob)
m_evaluateBlendClipAnimatorJobs[i]->addDependency(m_loadAnimationClipJob);
- if (jobs.contains(m_buildBlendTreesJob))
+ if (hasBuildBlendTreesJob)
m_evaluateBlendClipAnimatorJobs[i]->addDependency(m_buildBlendTreesJob);
jobs.push_back(m_evaluateBlendClipAnimatorJobs[i]);
}