Better bounds check in CFGAS_StringFormatter::GetCategory()
This allows the optimizer to remove the last implicit bounds
check in span indexing in GetCategory() and astonishingly saves
abou 36 bytes of generated code.
Change-Id: I94692418def8d1db78d64d7c86451de64f1a9396
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/51951
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fgas/crt/cfgas_stringformatter.cpp b/xfa/fgas/crt/cfgas_stringformatter.cpp
index fff66e0..156d068 100644
--- a/xfa/fgas/crt/cfgas_stringformatter.cpp
+++ b/xfa/fgas/crt/cfgas_stringformatter.cpp
@@ -859,7 +859,7 @@
WideString wsCategory(m_spPattern[ccf]);
ccf++;
while (true) {
- if (ccf == m_spPattern.size())
+ if (ccf >= m_spPattern.size())
return eCategory;
if (m_spPattern[ccf] == '.' || m_spPattern[ccf] == '(')
break;
@@ -870,7 +870,6 @@
wsCategory += m_spPattern[ccf];
ccf++;
}
-
uint32_t dwHash = FX_HashCode_GetW(wsCategory.AsStringView(), false);
if (dwHash == FX_LOCALECATEGORY_DateTimeHash)
return FX_LOCALECATEGORY_DateTime;