Avoid WideStringViews from constant strings in cfgas_stringformatter.cpp
Our CollectionSize() template (and std::find() under the covers) work
just fine on these constants as-is.
Change-Id: I61cd6f7b8a16c549959a0cd23cd9abe047f78fb6
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/51930
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fgas/crt/cfgas_stringformatter.cpp b/xfa/fgas/crt/cfgas_stringformatter.cpp
index 6b381e9..de91740 100644
--- a/xfa/fgas/crt/cfgas_stringformatter.cpp
+++ b/xfa/fgas/crt/cfgas_stringformatter.cpp
@@ -12,7 +12,7 @@
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_safe_types.h"
-#include "third_party/base/span.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fgas/crt/cfgas_decimal.h"
// NOTE: Code uses the convention for backwards-looping with unsigned types
@@ -238,7 +238,6 @@
size_t ccf = 0;
pdfium::span<const wchar_t> spDate = wsDate.AsSpan();
pdfium::span<const wchar_t> spDatePattern = wsDatePattern.AsSpan();
- WideStringView wsDateSymbols(gs_wsDateSymbols);
while (*cc < spDate.size() && ccf < spDatePattern.size()) {
if (spDatePattern[ccf] == '\'') {
WideString wsLiteral = GetLiteralText(spDatePattern, &ccf);
@@ -251,7 +250,7 @@
ccf++;
continue;
}
- if (!wsDateSymbols.Contains(spDatePattern[ccf])) {
+ if (!pdfium::ContainsValue(gs_wsDateSymbols, spDatePattern[ccf])) {
if (spDatePattern[ccf] != spDate[*cc])
return false;
(*cc)++;
@@ -361,7 +360,6 @@
pdfium::span<const wchar_t> spTimePattern = wsTimePattern.AsSpan();
bool bHasA = false;
bool bPM = false;
- WideStringView wsTimeSymbols(gs_wsTimeSymbols);
while (*cc < spTime.size() && ccf < spTimePattern.size()) {
if (spTimePattern[ccf] == '\'') {
WideString wsLiteral = GetLiteralText(spTimePattern, &ccf);
@@ -374,7 +372,7 @@
ccf++;
continue;
}
- if (!wsTimeSymbols.Contains(spTimePattern[ccf])) {
+ if (!pdfium::ContainsValue(gs_wsTimeSymbols, spTimePattern[ccf])) {
if (spTimePattern[ccf] != spTime[*cc])
return false;
(*cc)++;
@@ -573,18 +571,16 @@
uint8_t day = datetime.GetDay();
size_t ccf = 0;
pdfium::span<const wchar_t> spDatePattern = wsDatePattern.AsSpan();
- WideStringView wsDateSymbols(gs_wsDateSymbols);
while (ccf < spDatePattern.size()) {
if (spDatePattern[ccf] == '\'') {
wsResult += GetLiteralText(spDatePattern, &ccf);
ccf++;
continue;
}
- if (!wsDateSymbols.Contains(spDatePattern[ccf])) {
+ if (!pdfium::ContainsValue(gs_wsDateSymbols, spDatePattern[ccf])) {
wsResult += spDatePattern[ccf++];
continue;
}
-
WideString symbol;
symbol.Reserve(4);
symbol += spDatePattern[ccf++];