From 0bc60023f5e693c12751bec5db6ee4dbdfbc7d05 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 5 Mar 2024 17:51:50 +0200 Subject: [PATCH] plugins/shakecursor: Prefer operator[] over at() Bounds checks are redundant. Plus kwin is built with exceptions disabled. --- src/plugins/shakecursor/shakedetector.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/shakecursor/shakedetector.cpp b/src/plugins/shakecursor/shakedetector.cpp index 91bede4977..97eb9a15dc 100644 --- a/src/plugins/shakecursor/shakedetector.cpp +++ b/src/plugins/shakecursor/shakedetector.cpp @@ -58,15 +58,15 @@ bool ShakeDetector::update(QMouseEvent *event) for (size_t i = 1; i < m_history.size(); ++i) { // Compute the length of the mouse path. - const qreal deltaX = m_history.at(i).position.x() - m_history.at(i - 1).position.x(); - const qreal deltaY = m_history.at(i).position.y() - m_history.at(i - 1).position.y(); + const qreal deltaX = m_history[i].position.x() - m_history[i - 1].position.x(); + const qreal deltaY = m_history[i].position.y() - m_history[i - 1].position.y(); distance += std::sqrt(deltaX * deltaX + deltaY * deltaY); // Compute the bounds of the mouse path. - left = std::min(left, m_history.at(i).position.x()); - top = std::min(top, m_history.at(i).position.y()); - right = std::max(right, m_history.at(i).position.x()); - bottom = std::max(bottom, m_history.at(i).position.y()); + left = std::min(left, m_history[i].position.x()); + top = std::min(top, m_history[i].position.y()); + right = std::max(right, m_history[i].position.x()); + bottom = std::max(bottom, m_history[i].position.y()); } const qreal boundsWidth = right - left;