From 7e0d58b411170f8a71122f09f35f6ee0483db172 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 26 Jul 2017 16:33:45 -0400 Subject: Use std::min/max in fx_coordinates.h This CL updates some of the fx_coordinates methods to use std::min/max as appropriate. Change-Id: I12af519bfcbf97969da6fcc9e1bf978beb2d00e8 Reviewed-on: https://pdfium-review.googlesource.com/9113 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fxcrt/fx_coordinates.h | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h index 3ff5fb9480..517365ad64 100644 --- a/core/fxcrt/fx_coordinates.h +++ b/core/fxcrt/fx_coordinates.h @@ -7,6 +7,8 @@ #ifndef CORE_FXCRT_FX_COORDINATES_H_ #define CORE_FXCRT_FX_COORDINATES_H_ +#include + #include "core/fxcrt/fx_basic.h" class CFX_Matrix; @@ -340,14 +342,12 @@ class CFX_RTemplate { void Union(BaseType x, BaseType y) { BaseType r = right(); BaseType b = bottom(); - if (left > x) - left = x; - if (r < x) - r = x; - if (top > y) - top = y; - if (b < y) - b = y; + + left = std::min(left, x); + top = std::min(top, y); + r = std::max(r, x); + b = std::max(b, y); + width = r - left; height = b - top; } @@ -355,28 +355,24 @@ class CFX_RTemplate { void Union(const RectType& rt) { BaseType r = right(); BaseType b = bottom(); - if (left > rt.left) - left = rt.left; - if (r < rt.right()) - r = rt.right(); - if (top > rt.top) - top = rt.top; - if (b < rt.bottom()) - b = rt.bottom(); + + left = std::min(left, rt.left); + top = std::min(top, rt.top); + r = std::max(r, rt.right()); + b = std::max(b, rt.bottom()); + width = r - left; height = b - top; } void Intersect(const RectType& rt) { BaseType r = right(); BaseType b = bottom(); - if (left < rt.left) - left = rt.left; - if (r > rt.right()) - r = rt.right(); - if (top < rt.top) - top = rt.top; - if (b > rt.bottom()) - b = rt.bottom(); + + left = std::max(left, rt.left); + top = std::max(top, rt.top); + r = std::min(r, rt.right()); + b = std::min(b, rt.bottom()); + width = r - left; height = b - top; } -- cgit v1.2.3