Make one branch in CFXJSE_FormCalcContext::Str() faster.

Fill a vector in one go as the backing store for a ByteStringView,
instead of appending to std::ostringstream one character at a time.

Bug: pdfium:1760
Change-Id: Ia277386558413255490f94cc722a51ed2880bb69
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/88690
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index b320bdd..88d2616 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -4223,19 +4223,14 @@
     ++u;
   }
 
-  std::ostringstream resultBuf;
   if (u > iWidth || (iPrecision + u) >= iWidth) {
-    int32_t i = 0;
-    while (i < iWidth) {
-      resultBuf << '*';
-      ++i;
-    }
-    resultBuf << '\0';
-    info.GetReturnValue().Set(fxv8::NewStringHelper(
-        info.GetIsolate(), ByteStringView(resultBuf.str().c_str())));
+    std::vector<char, FxAllocAllocator<char>> stars(std::max(iWidth, 0), '*');
+    info.GetReturnValue().Set(
+        fxv8::NewStringHelper(info.GetIsolate(), ByteStringView(stars)));
     return;
   }
 
+  std::ostringstream resultBuf;
   if (u == iLength) {
     if (iLength > iWidth) {
       int32_t i = 0;