summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp28
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.h2
2 files changed, 12 insertions, 18 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index 0b8ea19ea5..94e3fb10cd 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -3579,7 +3579,7 @@ void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString,
while (i < iLen) {
uint32_t ch = pData[i];
CFX_WideString htmlReserve;
- if (HTMLCode2STR(ch, htmlReserve)) {
+ if (HTMLCode2STR(ch, &htmlReserve)) {
wsResultBuf.AppendChar(L'&');
wsResultBuf << htmlReserve;
wsResultBuf.AppendChar(L';');
@@ -3701,22 +3701,16 @@ bool CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData,
// static
bool CXFA_FM2JSContext::HTMLCode2STR(uint32_t iCode,
- CFX_WideString& wsHTMLReserve) {
- int32_t iStart = 0;
- int32_t iEnd = FX_ArraySize(reservesForEncode) - 1;
- do {
- int32_t iMid = (iStart + iEnd) / 2;
- XFA_FMHtmlReserveCode htmlreservecode = reservesForEncode[iMid];
- if (iCode == htmlreservecode.m_uCode) {
- wsHTMLReserve = htmlreservecode.m_htmlReserve;
- return true;
- }
-
- if (iCode < htmlreservecode.m_uCode)
- iEnd = iMid - 1;
- else
- iStart = iMid + 1;
- } while (iStart <= iEnd);
+ CFX_WideString* wsHTMLReserve) {
+ const XFA_FMHtmlReserveCode* result = std::lower_bound(
+ std::begin(reservesForEncode), std::end(reservesForEncode), iCode,
+ [](const XFA_FMHtmlReserveCode iter, const uint32_t& val) {
+ return iter.m_uCode < val;
+ });
+ if (result != std::end(reservesForEncode) && result->m_uCode == iCode) {
+ *wsHTMLReserve = result->m_htmlReserve;
+ return true;
+ }
return false;
}
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.h b/xfa/fxfa/fm2js/cxfa_fm2jscontext.h
index 63fc0f42bd..a5769a36cc 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.h
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.h
@@ -240,7 +240,7 @@ class CXFA_FM2JSContext : public CFXJSE_HostObject {
static void EncodeXML(const CFX_ByteStringC& szXMLString,
CFX_ByteTextBuf& szResultBuf);
static bool HTMLSTR2Code(const CFX_WideStringC& pData, uint32_t& iCode);
- static bool HTMLCode2STR(uint32_t iCode, CFX_WideString& wsHTMLReserve);
+ static bool HTMLCode2STR(uint32_t iCode, CFX_WideString* wsHTMLReserve);
static void Format(CFXJSE_Value* pThis,
const CFX_ByteStringC& szFuncName,
CFXJSE_Arguments& args);