Use appropriate sequence algorithms in IdleInhibition

Summary: This simplifies code a little bit.

Test Plan: Compiles, existing tests pass.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17353
icc-effect-5.17.5
Vlad Zagorodniy 2019-01-11 15:21:20 +02:00
parent 2e2a462733
commit 4fac71d697
2 changed files with 3 additions and 4 deletions

View File

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Server/idle_interface.h>
#include <KWayland/Server/surface_interface.h>
#include <algorithm>
#include <functional>
using KWayland::Server::SurfaceInterface;
@ -82,7 +83,7 @@ void IdleInhibition::inhibit(AbstractClient *client)
void IdleInhibition::uninhibit(AbstractClient *client)
{
auto it = std::find_if(m_idleInhibitors.begin(), m_idleInhibitors.end(), [client] (auto c) { return c == client; });
auto it = std::find(m_idleInhibitors.begin(), m_idleInhibitors.end(), client);
if (it == m_idleInhibitors.end()) {
// not inhibited
return;

View File

@ -24,8 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QVector>
#include <QMap>
#include <algorithm>
namespace KWayland
{
namespace Server
@ -54,7 +52,7 @@ public:
return !m_idleInhibitors.isEmpty();
}
bool isInhibited(AbstractClient *client) const {
return std::any_of(m_idleInhibitors.begin(), m_idleInhibitors.end(), [client] (auto c) { return c == client; });
return m_idleInhibitors.contains(client);
}
private Q_SLOTS: