summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-05-08 15:30:07 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-08 15:30:07 +0000
commit3645dbcf8f6b830ad5b371b9aaae6ee2be33eb98 (patch)
tree018b8ff4fa4e16dfefc41f72beae1323cb625ec8 /xfa/fxfa/fm2js/cxfa_fmexpression.cpp
parentdec08c8d3fbc4e89748f2d655b32727cfab373ed (diff)
downloadpdfium-3645dbcf8f6b830ad5b371b9aaae6ee2be33eb98.tar.xz
[fm2js] Create fewer CFX_WideTextBuf classes
This CL modifies the formcalc transpiler to create less CFX_WideTextBuf classes as we convert to JavaScript. This can take some pathalogical formcal from 20sec to convert to .5sec. Bug: chromium:834575 Change-Id: I428883297bbc3a6a325a4ab0ad51834f2f02ab82 Reviewed-on: https://pdfium-review.googlesource.com/32154 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js/cxfa_fmexpression.cpp')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmexpression.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
index b2995cae4c..a3c65a2203 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
@@ -362,24 +362,23 @@ bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
WideString tmpName = IdentifierToName(m_wsVariant);
js << L"var " << tmpName << L" = null;\n";
- CFX_WideTextBuf assign_txt;
- if (!m_pAssignment->ToJavaScript(assign_txt, ReturnType::kInfered))
+ js << L"for (" << tmpName << L" = pfm_rt.get_val(";
+ if (!m_pAssignment->ToJavaScript(js, ReturnType::kInfered))
return false;
+ js << L"); ";
- CFX_WideTextBuf accessor_txt;
- if (!m_pAccessor->ToJavaScript(accessor_txt, ReturnType::kInfered))
+ js << tmpName << (m_bDirection ? kLessEqual : kGreaterEqual);
+ js << L"pfm_rt.get_val(";
+ if (!m_pAccessor->ToJavaScript(js, ReturnType::kInfered))
return false;
+ js << L"); ";
- js << L"for (" << tmpName << L" = pfm_rt.get_val(" << assign_txt << L"); ";
- js << tmpName << (m_bDirection ? kLessEqual : kGreaterEqual);
- js << L"pfm_rt.get_val(" << accessor_txt << L"); ";
js << tmpName << (m_bDirection ? kPlusEqual : kMinusEqual);
if (m_pStep) {
- CFX_WideTextBuf step_txt;
- if (!m_pStep->ToJavaScript(step_txt, ReturnType::kInfered))
+ js << L"pfm_rt.get_val(";
+ if (!m_pStep->ToJavaScript(js, ReturnType::kInfered))
return false;
-
- js << L"pfm_rt.get_val(" << step_txt << L")";
+ js << L")";
} else {
js << L"1";
}