Use operator== instead of Compare(). Replace str.Compare(foo) == 0 with str == foo. Change-Id: I67bd54a1b1621dea67dcc3f83c176a5db8cb2341 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79874 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index 8271890..42045a0 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -392,10 +392,9 @@ return false; m_BaseFontName = pCIDFontDict->GetStringFor("BaseFont"); - if ((m_BaseFontName.Compare("CourierStd") == 0 || - m_BaseFontName.Compare("CourierStd-Bold") == 0 || - m_BaseFontName.Compare("CourierStd-BoldOblique") == 0 || - m_BaseFontName.Compare("CourierStd-Oblique") == 0) && + if ((m_BaseFontName == "CourierStd" || m_BaseFontName == "CourierStd-Bold" || + m_BaseFontName == "CourierStd-BoldOblique" || + m_BaseFontName == "CourierStd-Oblique") && !IsEmbedded()) { m_bAdobeCourierStd = true; }
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp index b90accd..8986705 100644 --- a/core/fpdfapi/font/cpdf_simplefont.cpp +++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -121,7 +121,7 @@ return; } ByteString bsEncoding = pEncoding->GetString(); - if (bsEncoding.Compare("MacExpertEncoding") == 0) { + if (bsEncoding == "MacExpertEncoding") { bsEncoding = "WinAnsiEncoding"; } GetPredefinedEncoding(bsEncoding, &m_BaseEncoding); @@ -135,7 +135,7 @@ if (m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS) { ByteString bsEncoding = pDict->GetStringFor("BaseEncoding"); - if (bTrueType && bsEncoding.Compare("MacExpertEncoding") == 0) + if (bTrueType && bsEncoding == "MacExpertEncoding") bsEncoding = "WinAnsiEncoding"; GetPredefinedEncoding(bsEncoding, &m_BaseEncoding); }
diff --git a/core/fpdfdoc/cpdf_bafontmap.cpp b/core/fpdfdoc/cpdf_bafontmap.cpp index 9f4d65c..4ef2c11 100644 --- a/core/fpdfdoc/cpdf_bafontmap.cpp +++ b/core/fpdfdoc/cpdf_bafontmap.cpp
@@ -38,11 +38,11 @@ pFontMapper->LoadInstalledFonts(); for (const auto& font : pFontMapper->m_InstalledTTFonts) { - if (font.Compare(sFontFaceName) == 0) + if (font == sFontFaceName) return true; } for (const auto& fontPair : pFontMapper->m_LocalizedTTFonts) { - if (fontPair.first.Compare(sFontFaceName) == 0) + if (fontPair.first == sFontFaceName) return true; } return false;
diff --git a/core/fpdfdoc/cpdf_generateap.cpp b/core/fpdfdoc/cpdf_generateap.cpp index 70bbcc9..b26b121 100644 --- a/core/fpdfdoc/cpdf_generateap.cpp +++ b/core/fpdfdoc/cpdf_generateap.cpp
@@ -62,8 +62,8 @@ if (!pPDFFont) return ByteString(); - if (pPDFFont->GetBaseFontName().Compare("Symbol") == 0 || - pPDFFont->GetBaseFontName().Compare("ZapfDingbats") == 0) { + if (pPDFFont->GetBaseFontName() == "Symbol" || + pPDFFont->GetBaseFontName() == "ZapfDingbats") { return ByteString::Format("%c", Word); }
diff --git a/core/fxcrt/css/cfx_cssdata.cpp b/core/fxcrt/css/cfx_cssdata.cpp index cfef220..0e9afb1 100644 --- a/core/fxcrt/css/cfx_cssdata.cpp +++ b/core/fxcrt/css/cfx_cssdata.cpp
@@ -324,7 +324,7 @@ for (auto* iter = std::begin(lengthUnitTable); iter != std::end(lengthUnitTable); ++iter) { - if (lowerName.Compare(iter->value) == 0) + if (lowerName == iter->value) return iter; } @@ -340,7 +340,7 @@ for (auto* iter = std::begin(colorTable); iter != std::end(colorTable); ++iter) { - if (lowerName.Compare(iter->name) == 0) + if (lowerName == iter->name) return iter; } return nullptr;
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp index 0f6df7a..59f7716 100644 --- a/core/fxcrt/xml/cfx_xmlparser.cpp +++ b/core/fxcrt/xml/cfx_xmlparser.cpp
@@ -504,15 +504,15 @@ if (character != 0) current_text_.push_back(character); } else { - if (csEntity.Compare(L"amp") == 0) { + if (csEntity == L"amp") { current_text_.push_back(L'&'); - } else if (csEntity.Compare(L"lt") == 0) { + } else if (csEntity == L"lt") { current_text_.push_back(L'<'); - } else if (csEntity.Compare(L"gt") == 0) { + } else if (csEntity == L"gt") { current_text_.push_back(L'>'); - } else if (csEntity.Compare(L"apos") == 0) { + } else if (csEntity == L"apos") { current_text_.push_back(L'\''); - } else if (csEntity.Compare(L"quot") == 0) { + } else if (csEntity == L"quot") { current_text_.push_back(L'"'); } }
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp index 4e23c31..1a09bf8 100644 --- a/core/fxge/cfx_fontmapper.cpp +++ b/core/fxge/cfx_fontmapper.cpp
@@ -232,10 +232,10 @@ continue; if (bReverse) { - if (bsStyle.Last(pStyle->len).Compare(pStyle->name) == 0) + if (bsStyle.Last(pStyle->len) == pStyle->name) return std::make_tuple(true, pStyle->style, pStyle->len); } else { - if (bsStyle.First(pStyle->len).Compare(pStyle->name) == 0) + if (bsStyle.First(pStyle->len) == pStyle->name) return std::make_tuple(true, pStyle->style, pStyle->len); } }
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp index 2f8c54e..30db260 100644 --- a/fpdfsdk/cpdfsdk_helpers.cpp +++ b/fpdfsdk/cpdfsdk_helpers.cpp
@@ -360,7 +360,7 @@ if (pArray) { for (size_t i = 0; i < pArray->size(); i++) { ByteString cbStr = pArray->GetStringAt(i); - if (cbStr.Compare("com.adobe.acrobat.SharedReview.Register") == 0) { + if (cbStr == "com.adobe.acrobat.SharedReview.Register") { RaiseUnsupportedError(FPDF_UNSP_DOC_SHAREDREVIEW); break; }
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp index d837bff..5d7d613 100644 --- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -325,7 +325,7 @@ } CBC_QRCoderMode* ChooseMode(const ByteString& content, ByteString encoding) { - if (encoding.Compare("SHIFT_JIS") == 0) + if (encoding == "SHIFT_JIS") return CBC_QRCoderMode::sKANJI; bool hasNumeric = false;
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index 11f32f9..6549ee8 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp
@@ -929,7 +929,7 @@ int nMonth = 1; sTemp = wsArray[1]; for (size_t i = 0; i < pdfium::size(fxjs::kMonths); ++i) { - if (sTemp.Compare(fxjs::kMonths[i]) == 0) { + if (sTemp == fxjs::kMonths[i]) { nMonth = i + 1; break; }
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp index 92880c0..54b1763 100644 --- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
@@ -450,7 +450,7 @@ return val.Compare(iter.m_wsSomMethodName) > 0; }); if (result != std::end(gs_FMSomMethods) && - methodName.Compare(result->m_wsSomMethodName) == 0) { + methodName == result->m_wsSomMethodName) { return result->m_dParameters; } return 0;