From c16ab75eb98733c857723f9c2947c77a56b2bb02 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 20 Apr 2017 13:46:05 -0700 Subject: 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 Commit-Queue: Tom Sepez --- xfa/fxfa/parser/cxfa_dataexporter.cpp | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index 70748f2666..dda93a36fc 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -49,25 +49,9 @@ CFX_WideString ExportEncodeAttribute(const CFX_WideString& str) { 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) { -- cgit v1.2.3