Remove hand-written bsearch from cxfa_dataexporter.cpp
Binary search over an array of 5 elements is overkill.
Change-Id: I3a39e82035d67564012c11aaf78045e435d59a41
Reviewed-on: https://pdfium-review.googlesource.com/4396
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 70748f2..dda93a3 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -49,25 +49,9 @@
return textBuf.MakeString();
}
-const uint16_t g_XMLValidCharRange[][2] = {{0x09, 0x09},
- {0x0A, 0x0A},
- {0x0D, 0x0D},
- {0x20, 0xD7FF},
- {0xE000, 0xFFFD}};
bool IsXMLValidChar(wchar_t ch) {
- int32_t iStart = 0;
- int32_t iEnd = FX_ArraySize(g_XMLValidCharRange) - 1;
- while (iStart <= iEnd) {
- int32_t iMid = (iStart + iEnd) / 2;
- if (ch < g_XMLValidCharRange[iMid][0]) {
- iEnd = iMid - 1;
- } else if (ch > g_XMLValidCharRange[iMid][1]) {
- iStart = iMid + 1;
- } else {
- return true;
- }
- }
- return false;
+ return ch == 0x09 || ch == 0x0A || ch == 0x0D ||
+ (ch >= 0x20 && ch <= 0xD7FF) || (ch >= 0xE000 && ch <= 0xFFFD);
}
CFX_WideString ExportEncodeContent(const CFX_WideStringC& str) {