projects
/
dcpomatic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
790db8f
)
Cleanup: simplify some code.
author
Carl Hetherington
<cth@carlh.net>
Sat, 24 Dec 2022 22:52:25 +0000
(23:52 +0100)
committer
Carl Hetherington
<cth@carlh.net>
Sat, 24 Dec 2022 22:52:25 +0000
(23:52 +0100)
src/lib/job_manager.cc
patch
|
blob
|
history
diff --git
a/src/lib/job_manager.cc
b/src/lib/job_manager.cc
index e17b12853747b2ac8db640f6e22a500e3611c332..7a6bda8405b32240ae18bd9211e65abfe228a060 100644
(file)
--- a/
src/lib/job_manager.cc
+++ b/
src/lib/job_manager.cc
@@
-295,50
+295,34
@@
JobManager::analyse_subtitles (
void
JobManager::increase_priority (shared_ptr<Job> job)
{
void
JobManager::increase_priority (shared_ptr<Job> job)
{
- bool changed = false;
-
{
boost::mutex::scoped_lock lm (_mutex);
{
boost::mutex::scoped_lock lm (_mutex);
- auto last = _jobs.end ();
- for (auto i = _jobs.begin(); i != _jobs.end(); ++i) {
- if (*i == job && last != _jobs.end()) {
- swap (*i, *last);
- changed = true;
- break;
- }
- last = i;
+ auto iter = std::find(_jobs.begin(), _jobs.end(), job);
+ if (iter == _jobs.begin() || iter == _jobs.end()) {
+ return;
}
}
+ swap(*iter, *std::prev(iter));
}
}
- if (changed) {
- _empty_condition.notify_all ();
- emit (boost::bind(boost::ref(JobsReordered)));
- }
+ _empty_condition.notify_all();
+ emit(boost::bind(boost::ref(JobsReordered)));
}
void
JobManager::decrease_priority (shared_ptr<Job> job)
{
}
void
JobManager::decrease_priority (shared_ptr<Job> job)
{
- bool changed = false;
-
{
boost::mutex::scoped_lock lm (_mutex);
{
boost::mutex::scoped_lock lm (_mutex);
- for (auto i = _jobs.begin(); i != _jobs.end(); ++i) {
- auto next = i;
- ++next;
- if (*i == job && next != _jobs.end()) {
- swap (*i, *next);
- changed = true;
- break;
- }
+ auto iter = std::find(_jobs.begin(), _jobs.end(), job);
+ if (iter == _jobs.end() || std::next(iter) == _jobs.end()) {
+ return;
}
}
+ swap(*iter, *std::next(iter));
}
}
- if (changed) {
- _empty_condition.notify_all ();
- emit (boost::bind(boost::ref(JobsReordered)));
- }
+ _empty_condition.notify_all();
+ emit(boost::bind(boost::ref(JobsReordered)));
}
}