From: Joel Holdsworth Date: Sun, 28 Dec 2014 21:00:33 +0000 (+0000) Subject: Viewport: Use fabs instead of branch X-Git-Tag: pulseview-0.3.0~297 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1c91f1a230ac7f61ad0c2ed9718d12514353b629;p=pulseview.git Viewport: Use fabs instead of branch --- diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index 971eb755..0e89f3ad 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -92,9 +92,8 @@ bool Viewport::touch_event(QTouchEvent *event) double w = touchPoint1.pos().x() - touchPoint0.pos().x(); if (abs(w) >= 1.0) { - double scale = (pinch_offset1_ - pinch_offset0_) / w; - if (scale < 0) - scale = -scale; + const double scale = + fabs((pinch_offset1_ - pinch_offset0_) / w); double offset = pinch_offset0_ - touchPoint0.pos().x() * scale; if (scale > 0) view_.set_scale_offset(scale, offset);