Kill off most remaining wide string literal comparisons
Change-Id: I645b8d5aafe5c7428ca07d9526cb7bebf82208a3
Reviewed-on: https://pdfium-review.googlesource.com/c/46331
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp
index 402f064..2ea1e0f 100644
--- a/core/fpdfdoc/cpdf_filespec.cpp
+++ b/core/fpdfdoc/cpdf_filespec.cpp
@@ -187,7 +187,7 @@
return L'/' + ChangeSlashToPDF(filepath.c_str());
return ChangeSlashToPDF(filepath.c_str());
#elif _FX_PLATFORM_ == _FX_PLATFORM_APPLE_
- if (filepath.Left(sizeof("Mac") - 1) == L"Mac")
+ if (filepath.Left(sizeof("Mac") - 1).EqualsASCII("Mac"))
return L'/' + ChangeSlashToPDF(filepath.c_str());
return ChangeSlashToPDF(filepath.c_str());
#else
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 7fc1554..e111fbc 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -231,7 +231,7 @@
SetCData(eAttr, WideString(wsValue), bNotify, false);
break;
case XFA_AttributeType::Boolean:
- SetBoolean(eAttr, wsValue != L"0", bNotify);
+ SetBoolean(eAttr, !wsValue.EqualsASCII("0"), bNotify);
break;
case XFA_AttributeType::Integer:
SetInteger(eAttr,
diff --git a/xfa/fde/cfde_texteditengine.cpp b/xfa/fde/cfde_texteditengine.cpp
index 5a2a904..878c488 100644
--- a/xfa/fde/cfde_texteditengine.cpp
+++ b/xfa/fde/cfde_texteditengine.cpp
@@ -873,7 +873,7 @@
ClearSelection();
// The JS requested the insertion of text instead of just a deletion.
- if (change.text != L"")
+ if (!change.text.IsEmpty())
Insert(start_idx, change.text, RecordOperation::kSkipRecord);
if (delegate_)
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
index 6e1b9b1..e33b852 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
@@ -155,21 +155,21 @@
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
- if (m_wsIdentifier == L"$")
+ if (m_wsIdentifier.EqualsASCII("$"))
*js << "this";
- else if (m_wsIdentifier == L"!")
+ else if (m_wsIdentifier.EqualsASCII("!"))
*js << "xfa.datasets";
- else if (m_wsIdentifier == L"$data")
+ else if (m_wsIdentifier.EqualsASCII("$data"))
*js << "xfa.datasets.data";
- else if (m_wsIdentifier == L"$event")
+ else if (m_wsIdentifier.EqualsASCII("$event"))
*js << "xfa.event";
- else if (m_wsIdentifier == L"$form")
+ else if (m_wsIdentifier.EqualsASCII("$form"))
*js << "xfa.form";
- else if (m_wsIdentifier == L"$host")
+ else if (m_wsIdentifier.EqualsASCII("$host"))
*js << "xfa.host";
- else if (m_wsIdentifier == L"$layout")
+ else if (m_wsIdentifier.EqualsASCII("$layout"))
*js << "xfa.layout";
- else if (m_wsIdentifier == L"$template")
+ else if (m_wsIdentifier.EqualsASCII("$template"))
*js << "xfa.template";
else if (m_wsIdentifier[0] == L'!')
*js << "pfm__excl__"
@@ -211,7 +211,7 @@
*js << "pfm_rt.asgn_val_op(" << tempExp1 << ", " << tempExp2 << ");\n}\n";
if (m_pExp1->GetOperatorToken() == TOKidentifier &&
- tempExp1.AsStringView() != L"this") {
+ !tempExp1.AsStringView().EqualsASCII("this")) {
*js << "else\n{\n";
if (type == ReturnType::kImplied)
*js << "pfm_ret = ";
@@ -489,11 +489,11 @@
return false;
}
- if (funcName.AsStringView() == L"Eval") {
+ if (funcName.AsStringView().EqualsASCII("Eval")) {
isEvalFunc = true;
*js << "eval.call(this, pfm_rt.Translate";
} else {
- if (funcName.AsStringView() == L"Exists")
+ if (funcName.AsStringView().EqualsASCII("Exists"))
isExistsFunc = true;
*js << "pfm_rt." << funcName;
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index f041a92..37eee55 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -1551,7 +1551,7 @@
wsSOM = WideStringView(wsUseVal.c_str(), wsUseVal.GetLength());
}
}
- if (!wsURI.IsEmpty() && wsURI != L".")
+ if (!wsURI.IsEmpty() && !wsURI.EqualsASCII("."))
continue;
CXFA_Node* pProtoNode = nullptr;
diff --git a/xfa/fxfa/parser/cxfa_measurement.cpp b/xfa/fxfa/parser/cxfa_measurement.cpp
index d0534c9..05089c7 100644
--- a/xfa/fxfa/parser/cxfa_measurement.cpp
+++ b/xfa/fxfa/parser/cxfa_measurement.cpp
@@ -129,21 +129,21 @@
// static
XFA_Unit CXFA_Measurement::GetUnitFromString(const WideStringView& wsUnit) {
- if (wsUnit == L"mm")
+ if (wsUnit.EqualsASCII("mm"))
return XFA_Unit::Mm;
- if (wsUnit == L"pt")
+ if (wsUnit.EqualsASCII("pt"))
return XFA_Unit::Pt;
- if (wsUnit == L"in")
+ if (wsUnit.EqualsASCII("in"))
return XFA_Unit::In;
- if (wsUnit == L"cm")
+ if (wsUnit.EqualsASCII("cm"))
return XFA_Unit::Cm;
- if (wsUnit == L"pc")
+ if (wsUnit.EqualsASCII("pc"))
return XFA_Unit::Pc;
- if (wsUnit == L"mp")
+ if (wsUnit.EqualsASCII("mp"))
return XFA_Unit::Mp;
- if (wsUnit == L"em")
+ if (wsUnit.EqualsASCII("em"))
return XFA_Unit::Em;
- if (wsUnit == L"%")
+ if (wsUnit.EqualsASCII("%"))
return XFA_Unit::Percent;
return XFA_Unit::Unknown;
}