From 007e6c0f9559412788b903bcb6a7601e220c3be8 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 26 Feb 2016 14:31:56 -0800 Subject: Remove some FX_BOOLs Grepping for FX_BOOL and |==| on the same line gives a very strong clue that the expression won't be out of range of the |bool| type iteself. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1736323003 . --- fpdfsdk/include/fsdk_baseannot.h | 14 +++++++------- fpdfsdk/include/fxedit/fxet_list.h | 6 ++---- fpdfsdk/include/pdfwindow/PWL_Wnd.h | 6 +++--- 3 files changed, 12 insertions(+), 14 deletions(-) (limited to 'fpdfsdk/include') diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h index c0ed529782..8cee331f64 100644 --- a/fpdfsdk/include/fsdk_baseannot.h +++ b/fpdfsdk/include/fsdk_baseannot.h @@ -36,19 +36,19 @@ class CPDFSDK_DateTime { CPDFSDK_DateTime& operator=(const CPDFSDK_DateTime& datetime); CPDFSDK_DateTime& operator=(const FX_SYSTEMTIME& st); - FX_BOOL operator==(CPDFSDK_DateTime& datetime); - FX_BOOL operator!=(CPDFSDK_DateTime& datetime); - FX_BOOL operator>(CPDFSDK_DateTime& datetime); - FX_BOOL operator>=(CPDFSDK_DateTime& datetime); - FX_BOOL operator<(CPDFSDK_DateTime& datetime); - FX_BOOL operator<=(CPDFSDK_DateTime& datetime); + bool operator==(const CPDFSDK_DateTime& datetime) const; + bool operator!=(const CPDFSDK_DateTime& datetime) const; + bool operator>(const CPDFSDK_DateTime& datetime) const; + bool operator>=(const CPDFSDK_DateTime& datetime) const; + bool operator<(const CPDFSDK_DateTime& datetime) const; + bool operator<=(const CPDFSDK_DateTime& datetime) const; operator time_t(); CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr); CFX_ByteString ToCommonDateTimeString(); CFX_ByteString ToPDFDateTimeString(); void ToSystemTime(FX_SYSTEMTIME& st); - CPDFSDK_DateTime ToGMT(); + CPDFSDK_DateTime ToGMT() const; CPDFSDK_DateTime& AddDays(short days); CPDFSDK_DateTime& AddSeconds(int seconds); diff --git a/fpdfsdk/include/fxedit/fxet_list.h b/fpdfsdk/include/fxedit/fxet_list.h index 88d57c4928..a02cd8a45e 100644 --- a/fpdfsdk/include/fxedit/fxet_list.h +++ b/fpdfsdk/include/fxedit/fxet_list.h @@ -67,13 +67,11 @@ class CLST_Rect : public CFX_FloatRect { return *this; } - FX_BOOL operator==(const CLST_Rect& rect) const { + bool operator==(const CLST_Rect& rect) const { return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) == 0; } - FX_BOOL operator!=(const CLST_Rect& rect) const { - return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) != 0; - } + bool operator!=(const CLST_Rect& rect) const { return !(*this == rect); } FX_FLOAT Width() const { return right - left; } diff --git a/fpdfsdk/include/pdfwindow/PWL_Wnd.h b/fpdfsdk/include/pdfwindow/PWL_Wnd.h index 19046e6c9c..493cdc0874 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Wnd.h +++ b/fpdfsdk/include/pdfwindow/PWL_Wnd.h @@ -134,7 +134,7 @@ struct CPWL_Color { FX_FLOAT fColor1, fColor2, fColor3, fColor4; }; -inline FX_BOOL operator==(const CPWL_Color& c1, const CPWL_Color& c2) { +inline bool operator==(const CPWL_Color& c1, const CPWL_Color& c2) { return c1.nColorType == c2.nColorType && c1.fColor1 - c2.fColor1 < 0.0001 && c1.fColor1 - c2.fColor1 > -0.0001 && c1.fColor2 - c2.fColor2 < 0.0001 && @@ -144,8 +144,8 @@ inline FX_BOOL operator==(const CPWL_Color& c1, const CPWL_Color& c2) { c1.fColor4 - c2.fColor4 < 0.0001 && c1.fColor4 - c2.fColor4 > -0.0001; } -inline FX_BOOL operator!=(const CPWL_Color& c1, const CPWL_Color& c2) { - return !operator==(c1, c2); +inline bool operator!=(const CPWL_Color& c1, const CPWL_Color& c2) { + return !(c1 == c2); } #define PWL_SCROLLBAR_WIDTH 12.0f -- cgit v1.2.3