include/tools/helpers.hxx |   37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

New commits:
commit 96b08e181cdefce24ddc25fdbf0648856cbb7b0f
Author: Chris Sherlock <chris.sherloc...@gmail.com>
Date:   Wed Apr 25 21:39:05 2018 +1000

    tools: make MinMax functions easier to read
    
    Change-Id: Ief624d353daf5fb321425b396b22c9e9b56806e9
    Reviewed-on: https://gerrit.libreoffice.org/53452
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/tools/helpers.hxx b/include/tools/helpers.hxx
index 0a349ea62d1d..da815e13b5e9 100644
--- a/include/tools/helpers.hxx
+++ b/include/tools/helpers.hxx
@@ -22,8 +22,17 @@ typename std::enable_if<
 MinMax(T nVal, long nMin, long nMax)
 {
     assert(nMin <= nMax);
-    return nVal >= nMin
-        ? (nVal <= nMax ? static_cast<long>(nVal) : nMax) : nMin;
+    if (nVal >= nMin)
+    {
+        if (nVal <= nMax)
+            return static_cast<long>(nVal);
+        else
+           return nMax;
+    }
+    else
+    {
+        return nMin;
+    }
 }
 
 template<typename T>
@@ -33,12 +42,24 @@ typename std::enable_if<
 MinMax(T nVal, long nMin, long nMax)
 {
     assert(nMin <= nMax);
-    return nMax < 0
-        ? nMax
-        : ((nMin < 0 || nVal >= static_cast<unsigned long>(nMin))
-           ? (nVal <= static_cast<unsigned long>(nMax)
-              ? static_cast<long>(nVal) : nMax)
-           : nMin);
+    if (nMax < 0)
+    {
+        return nMax;
+    }
+    else
+    {
+        if (nMin < 0 || nVal >= static_cast<unsigned long>(nMin))
+        {
+            if (nVal <= static_cast<unsigned long>(nMax))
+                return static_cast<long>(nVal);
+            else
+                return nMax;
+        }
+        else
+        {
+            return nMin;
+        }
+    }
 }
 
 inline sal_uInt32 AlignedWidth4Bytes(sal_uInt32 nWidthBits)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to