Prefer (!X || Y) to (X ? Y : true)
Small code cleanup. No functional change intended.
Change-Id: I463712d56761c3f12ab63b1f5615cdc851129477
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/63691
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpdf_viewerpreferences.cpp b/core/fpdfdoc/cpdf_viewerpreferences.cpp
index 491b376..be07fdc 100644
--- a/core/fpdfdoc/cpdf_viewerpreferences.cpp
+++ b/core/fpdfdoc/cpdf_viewerpreferences.cpp
@@ -22,7 +22,7 @@
bool CPDF_ViewerPreferences::PrintScaling() const {
const CPDF_Dictionary* pDict = GetViewerPreferences();
- return pDict ? pDict->GetStringFor("PrintScaling") != "None" : true;
+ return !pDict || pDict->GetStringFor("PrintScaling") != "None";
}
int32_t CPDF_ViewerPreferences::NumCopies() const {
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index ec550b7..ca8d591 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1581,7 +1581,7 @@
bool CFX_AggDeviceDriver::ContinueDIBits(CFX_ImageRenderer* pHandle,
PauseIndicatorIface* pPause) {
- return m_pBitmap->GetBuffer() ? pHandle->Continue(pPause) : true;
+ return !m_pBitmap->GetBuffer() || pHandle->Continue(pPause);
}
#ifndef _SKIA_SUPPORT_
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index 3c0e888..ef334a3 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -290,7 +290,7 @@
} else if (pNode && pNode->GetElementType() == XFA_Element::Integer) {
pValue->SetInteger(FXSYS_wtoi(content.c_str()));
} else if (pNode && pNode->GetElementType() == XFA_Element::Boolean) {
- pValue->SetBoolean(FXSYS_wtoi(content.c_str()) == 0 ? false : true);
+ pValue->SetBoolean(FXSYS_wtoi(content.c_str()) != 0);
} else if (pNode && pNode->GetElementType() == XFA_Element::Float) {
CFGAS_Decimal decimal(content.AsStringView());
pValue->SetFloat(decimal.ToFloat());
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index 688d136..32c642f 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -673,7 +673,7 @@
bool bLimit = true;
int32_t nCount = wsNumeric.GetLength();
int32_t nCountFmt = wsFormat.GetLength();
- while (n < nCount && (bLimit ? nf < nCountFmt : true) &&
+ while (n < nCount && (!bLimit || nf < nCountFmt) &&
FXSYS_IsDecimalDigit(c = spNum[n])) {
if (bLimit == true) {
if ((cf = spFmt[nf]) == L'*')