Prefer (X && Y) over (X ? Y : false).
Small coding style cleanup. No functional change intended.
Change-Id: If8175cf7fb34cfad678aad2c534160e0c226e40a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/63690
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 4373dd6..d7d2265 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -893,7 +893,7 @@
}
bool CPDF_VariableText::IsLatinWord(uint16_t word) {
- return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : false;
+ return m_pVTProvider && m_pVTProvider->IsLatinWord(word);
}
CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() {
diff --git a/core/fpdfdoc/cpdf_viewerpreferences.cpp b/core/fpdfdoc/cpdf_viewerpreferences.cpp
index 9e63d37..491b376 100644
--- a/core/fpdfdoc/cpdf_viewerpreferences.cpp
+++ b/core/fpdfdoc/cpdf_viewerpreferences.cpp
@@ -17,7 +17,7 @@
bool CPDF_ViewerPreferences::IsDirectionR2L() const {
const CPDF_Dictionary* pDict = GetViewerPreferences();
- return pDict ? pDict->GetStringFor("Direction") == "R2L" : false;
+ return pDict && pDict->GetStringFor("Direction") == "R2L";
}
bool CPDF_ViewerPreferences::PrintScaling() const {
diff --git a/core/fxge/cfx_glyphcache.cpp b/core/fxge/cfx_glyphcache.cpp
index f011a6b..ec9c886 100644
--- a/core/fxge/cfx_glyphcache.cpp
+++ b/core/fxge/cfx_glyphcache.cpp
@@ -232,7 +232,7 @@
const auto* pSubstFont = pFont->GetSubstFont();
int weight = pSubstFont ? pSubstFont->m_Weight : 0;
int angle = pSubstFont ? pSubstFont->m_ItalicAngle : 0;
- bool vertical = pSubstFont ? pFont->IsVertical() : false;
+ bool vertical = pSubstFont && pFont->IsVertical();
const PathMapKey key =
std::make_tuple(glyph_index, dest_width, weight, angle, vertical);
auto it = m_PathMap.find(key);
diff --git a/fpdfsdk/fpdf_editpath.cpp b/fpdfsdk/fpdf_editpath.cpp
index 1783035..d3058e5 100644
--- a/fpdfsdk/fpdf_editpath.cpp
+++ b/fpdfsdk/fpdf_editpath.cpp
@@ -230,5 +230,5 @@
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPathSegment_GetClose(FPDF_PATHSEGMENT segment) {
auto* pPathPoint = FXPathPointFromFPDFPathSegment(segment);
- return pPathPoint ? pPathPoint->m_CloseFigure : false;
+ return pPathPoint && pPathPoint->m_CloseFigure;
}
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index 0202cb4..e9ed669 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -622,17 +622,17 @@
bool CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd* pWnd) const {
CPWL_MsgControl* pCtrl = GetMsgControl();
- return pCtrl ? pCtrl->IsWndCaptureMouse(pWnd) : false;
+ return pCtrl && pCtrl->IsWndCaptureMouse(pWnd);
}
bool CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const {
CPWL_MsgControl* pCtrl = GetMsgControl();
- return pCtrl ? pCtrl->IsWndCaptureKeyboard(pWnd) : false;
+ return pCtrl && pCtrl->IsWndCaptureKeyboard(pWnd);
}
bool CPWL_Wnd::IsFocused() const {
CPWL_MsgControl* pCtrl = GetMsgControl();
- return pCtrl ? pCtrl->IsMainCaptureKeyboard(this) : false;
+ return pCtrl && pCtrl->IsMainCaptureKeyboard(this);
}
CFX_FloatRect CPWL_Wnd::GetFocusRect() const {
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index 3ef9014..72844b9 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -247,11 +247,11 @@
}
bool CFWL_Edit::Undo() {
- return CanUndo() ? m_pEditEngine->Undo() : false;
+ return CanUndo() && m_pEditEngine->Undo();
}
bool CFWL_Edit::Redo() {
- return CanRedo() ? m_pEditEngine->Redo() : false;
+ return CanRedo() && m_pEditEngine->Redo();
}
bool CFWL_Edit::CanUndo() {
diff --git a/xfa/fwl/cfx_barcode.cpp b/xfa/fwl/cfx_barcode.cpp
index 47ad6f4..086632d 100644
--- a/xfa/fwl/cfx_barcode.cpp
+++ b/xfa/fwl/cfx_barcode.cpp
@@ -70,23 +70,23 @@
}
bool CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) {
- return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : false;
+ return m_pBCEngine && m_pBCEngine->SetCharEncoding(encoding);
}
bool CFX_Barcode::SetModuleHeight(int32_t moduleHeight) {
- return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : false;
+ return m_pBCEngine && m_pBCEngine->SetModuleHeight(moduleHeight);
}
bool CFX_Barcode::SetModuleWidth(int32_t moduleWidth) {
- return m_pBCEngine ? m_pBCEngine->SetModuleWidth(moduleWidth) : false;
+ return m_pBCEngine && m_pBCEngine->SetModuleWidth(moduleWidth);
}
bool CFX_Barcode::SetHeight(int32_t height) {
- return m_pBCEngine ? m_pBCEngine->SetHeight(height) : false;
+ return m_pBCEngine && m_pBCEngine->SetHeight(height);
}
bool CFX_Barcode::SetWidth(int32_t width) {
- return m_pBCEngine ? m_pBCEngine->SetWidth(width) : false;
+ return m_pBCEngine && m_pBCEngine->SetWidth(width);
}
bool CFX_Barcode::SetPrintChecksum(bool checksum) {
diff --git a/xfa/fxfa/layout/cxfa_contentlayoutprocessor.cpp b/xfa/fxfa/layout/cxfa_contentlayoutprocessor.cpp
index 52e763b..926436a 100644
--- a/xfa/fxfa/layout/cxfa_contentlayoutprocessor.cpp
+++ b/xfa/fxfa/layout/cxfa_contentlayoutprocessor.cpp
@@ -2352,7 +2352,7 @@
Result eRetValue = Result::kDone;
if (!bNewRow || pProcessor->m_ePreProcessRs == Result::kDone) {
eRetValue = pProcessor->DoLayoutInternal(
- bTakeSpace ? bUseBreakControl : false,
+ bTakeSpace && bUseBreakControl,
bUseRealHeight ? fRealHeight - *fContentCurRowY : FLT_MAX,
bIsTransHeight ? fRealHeight - *fContentCurRowY : FLT_MAX,
pLayoutContext);
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index c324006..1902810 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -2735,7 +2735,7 @@
pContext->SetNodesOfRunScript(nullptr);
pContext->SetEventParam(nullptr);
- return {iRet, pTmpRetValue->IsBoolean() ? pTmpRetValue->ToBoolean() : false};
+ return {iRet, pTmpRetValue->IsBoolean() && pTmpRetValue->ToBoolean()};
}
std::pair<XFA_FFWidgetType, CXFA_Ui*>