summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-02-13 10:26:01 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-02-13 19:00:17 +0000
commitf0b65545313f065790de7f91c02e5dd160753abd (patch)
tree747c55722c6b45a979d5c2894a259396a3189ed7 /xfa/fxfa/fm2js
parent5fb0ad8adac5fcbf8c8f1965164f41d11c0af669 (diff)
downloadpdfium-f0b65545313f065790de7f91c02e5dd160753abd.tar.xz
Simplify FX_UTF8Encode variants.chromium/3012
Doing so reveals places where there are needless copies and conversions. Change-Id: I24a868d40aa63836f4167eaf4541964049df7916 Reviewed-on: https://pdfium-review.googlesource.com/2555 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js')
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp73
1 files changed, 25 insertions, 48 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index ba65beffc4..e8cb2d0279 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -2026,7 +2026,7 @@ bool CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis,
CFX_WideString wsRet;
widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
XFA_VALUEPICTURE_Display);
- strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
+ strLocalDate = wsRet.UTF8Encode();
return true;
}
@@ -2065,7 +2065,7 @@ bool CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis,
CFX_WideString wsRet;
widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
XFA_VALUEPICTURE_Display);
- strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
+ strLocalTime = wsRet.UTF8Encode();
return true;
}
@@ -2104,7 +2104,7 @@ bool CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis,
CFX_WideString wsRet;
widgetValue.FormatPatterns(wsRet, wsFormat, pLocale,
XFA_VALUEPICTURE_Display);
- strGMTTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
+ strGMTTime = wsRet.UTF8Encode();
return true;
}
@@ -2213,7 +2213,7 @@ void CXFA_FM2JSContext::GetLocalDateFormat(CFXJSE_Value* pThis,
pLocale->GetDateTimeSymbols(wsSymbols);
AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date);
}
- strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength());
+ strFormat = strRet.UTF8Encode();
}
// static
@@ -2264,7 +2264,7 @@ void CXFA_FM2JSContext::GetLocalTimeFormat(CFXJSE_Value* pThis,
pLocale->GetDateTimeSymbols(wsSymbols);
AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time);
}
- strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength());
+ strFormat = strRet.UTF8Encode();
}
// static
@@ -2959,10 +2959,8 @@ void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis,
CFXJSE_Context::Create(pIsolate, nullptr, nullptr));
auto returnValue = pdfium::MakeUnique<CFXJSE_Value>(pIsolate);
- CFX_WideString javaScript(wsJavaScriptBuf.AsStringC());
- pNewContext->ExecuteScript(
- FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(),
- returnValue.get());
+ pNewContext->ExecuteScript(FX_UTF8Encode(wsJavaScriptBuf.AsStringC()).c_str(),
+ returnValue.get());
args.GetReturnValue()->Assign(returnValue.get());
}
@@ -3428,11 +3426,8 @@ void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString,
++i;
}
wsResultBuf.AppendChar(0);
-
szResultString.Clear();
- szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(),
- wsResultBuf.GetLength())
- .AsStringC();
+ szResultString << FX_UTF8Encode(wsResultBuf.AsStringC());
}
// static
@@ -3508,9 +3503,7 @@ void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString,
wsResultBuf.AppendChar(0);
szResultString.Clear();
- szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(),
- wsResultBuf.GetLength())
- .AsStringC();
+ szResultString << FX_UTF8Encode(wsResultBuf.AsStringC());
}
// static
@@ -3610,10 +3603,8 @@ void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString,
iCode = 0;
}
wsXMLBuf.AppendChar(0);
-
szResultString.Clear();
- szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength())
- .AsStringC();
+ szResultString << FX_UTF8Encode(wsXMLBuf.AsStringC());
}
// static
@@ -3761,9 +3752,7 @@ void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString,
}
wsResultBuf.AppendChar(0);
szResultBuf.Clear();
-
- szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength())
- .AsStringC();
+ szResultBuf << FX_UTF8Encode(wsResultBuf.AsStringC());
}
// static
@@ -3813,9 +3802,7 @@ void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString,
}
wsResultBuf.AppendChar(0);
szResultBuf.Clear();
-
- szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength())
- .AsStringC();
+ szResultBuf << FX_UTF8Encode(wsResultBuf.AsStringC());
}
// static
@@ -3886,9 +3873,7 @@ void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString,
}
wsResultBuf.AppendChar(0);
szResultBuf.Clear();
-
- szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength())
- .AsStringC();
+ szResultBuf << FX_UTF8Encode(wsResultBuf.AsStringC());
}
// static
@@ -4009,8 +3994,7 @@ void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis,
return;
}
- args.GetReturnValue()->SetString(
- FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC());
+ args.GetReturnValue()->SetString(wsRet.UTF8Encode().AsStringC());
}
// static
@@ -4091,8 +4075,7 @@ void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis,
lowStringBuf.AppendChar(0);
args.GetReturnValue()->SetString(
- FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength())
- .AsStringC());
+ FX_UTF8Encode(lowStringBuf.AsStringC()).AsStringC());
}
// static
@@ -4156,7 +4139,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
return;
}
args.GetReturnValue()->SetString(
- FX_UTF8Encode(localeValue.GetValue()).AsStringC());
+ localeValue.GetValue().UTF8Encode().AsStringC());
return;
}
@@ -4173,7 +4156,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
return;
}
args.GetReturnValue()->SetString(
- FX_UTF8Encode(localeValue.GetValue()).AsStringC());
+ localeValue.GetValue().UTF8Encode().AsStringC());
return;
}
case XFA_VT_DATE: {
@@ -4185,7 +4168,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
return;
}
args.GetReturnValue()->SetString(
- FX_UTF8Encode(localeValue.GetValue()).AsStringC());
+ localeValue.GetValue().UTF8Encode().AsStringC());
return;
}
case XFA_VT_TIME: {
@@ -4197,7 +4180,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
return;
}
args.GetReturnValue()->SetString(
- FX_UTF8Encode(localeValue.GetValue()).AsStringC());
+ localeValue.GetValue().UTF8Encode().AsStringC());
return;
}
case XFA_VT_TEXT: {
@@ -4209,7 +4192,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
return;
}
args.GetReturnValue()->SetString(
- FX_UTF8Encode(localeValue.GetValue()).AsStringC());
+ localeValue.GetValue().UTF8Encode().AsStringC());
return;
}
case XFA_VT_FLOAT: {
@@ -4241,7 +4224,7 @@ void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
return;
}
args.GetReturnValue()->SetString(
- FX_UTF8Encode(localeValue2.GetValue()).AsStringC());
+ localeValue2.GetValue().UTF8Encode().AsStringC());
return;
}
}
@@ -4640,8 +4623,7 @@ void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis,
upperStringBuf.AppendChar(0);
args.GetReturnValue()->SetString(
- FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength())
- .AsStringC());
+ FX_UTF8Encode(upperStringBuf.AsStringC()).AsStringC());
}
// static
@@ -4931,10 +4913,7 @@ void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis,
pContext->ThrowServerDeniedException();
return;
}
-
- args.GetReturnValue()->SetString(
- FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength())
- .AsStringC());
+ args.GetReturnValue()->SetString(decodedResponse.UTF8Encode().AsStringC());
}
// static
@@ -5680,9 +5659,8 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
return;
}
- CFX_WideString javaScript = wsJavaScriptBuf.MakeString();
args.GetReturnValue()->SetString(
- FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).AsStringC());
+ FX_UTF8Encode(wsJavaScriptBuf.AsStringC()).AsStringC());
}
// static
@@ -6439,6 +6417,5 @@ void CXFA_FM2JSContext::ThrowException(const FX_WCHAR* str, ...) const {
va_start(arg_ptr, str);
wsMessage.FormatV(str, arg_ptr);
va_end(arg_ptr);
- FXJSE_ThrowMessage(
- FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
+ FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringC());
}