diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-07-26 16:33:45 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-26 21:02:38 +0000 |
commit | 7e0d58b411170f8a71122f09f35f6ee0483db172 (patch) | |
tree | e05b947d0906870dfffe57518a1208de71899cc7 | |
parent | 4c045529908423f3a7e301619fadce5ede508fa2 (diff) | |
download | pdfium-7e0d58b411170f8a71122f09f35f6ee0483db172.tar.xz |
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 <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | core/fxcrt/fx_coordinates.h | 44 |
1 files 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 <algorithm> + #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; } |