Remove string stream from CFXJSE_FormCalcContext::Stuff()
Much simpler to construct a byte string from an initializer
list in a single shot.
Change-Id: Ia61886cdd14bf1cc0ccb18392606497c3107d318
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/88890
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 0d2bf43..0f9245b 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -4327,21 +4327,11 @@
}
--iStart; // now zero-based.
- std::ostringstream szResult;
- int32_t i = 0;
- while (i < iStart) {
- szResult << static_cast<char>(bsSource[i]);
- ++i;
- }
- szResult << bsInsert.AsStringView();
- i = iStart + iDelete;
- while (i < iLength) {
- szResult << static_cast<char>(bsSource[i]);
- ++i;
- }
- szResult << '\0';
- info.GetReturnValue().Set(fxv8::NewStringHelper(
- info.GetIsolate(), ByteStringView(szResult.str().c_str())));
+ ByteString bsResult = {bsSource.AsStringView().First(iStart),
+ bsInsert.AsStringView(),
+ bsSource.AsStringView().Substr(iStart + iDelete)};
+ info.GetReturnValue().Set(
+ fxv8::NewStringHelper(info.GetIsolate(), bsResult.AsStringView()));
}
// static