diff options
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp')
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp | 28 |
1 files changed, 11 insertions, 17 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; } |