Avoid string stream in GetPopupContentsString().

Avoid copy from stream, and construct result in a single shot
from an initializer list.

-- put blank lines where they might make more sense.

Change-Id: I6de3319fcb51320324a8e24c3dc65218c9050ea9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/89050
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_generateap.cpp b/core/fpdfdoc/cpdf_generateap.cpp
index 276e3ef..0e1c481 100644
--- a/core/fpdfdoc/cpdf_generateap.cpp
+++ b/core/fpdfdoc/cpdf_generateap.cpp
@@ -371,8 +371,8 @@
   WideString swValue(pAnnotDict.GetUnicodeTextFor(pdfium::form_fields::kT));
   swValue += L'\n';
   swValue += pAnnotDict.GetUnicodeTextFor(pdfium::annotation::kContents);
-  CPVT_FontMap map(pDoc, nullptr, pDefFont, sFontName);
 
+  CPVT_FontMap map(pDoc, nullptr, pDefFont, sFontName);
   CPVT_VariableText::Provider prd(&map);
   CPVT_VariableText vt;
   vt.SetProvider(&prd);
@@ -380,10 +380,10 @@
   vt.SetFontSize(12);
   vt.SetAutoReturn(true);
   vt.SetMultiLine(true);
-
   vt.Initialize();
   vt.SetText(swValue);
   vt.RearrangeAll();
+
   CFX_PointF ptOffset(3.0f, -3.0f);
   ByteString sContent =
       GenerateEditAP(&map, vt.GetIterator(), ptOffset, false, 0);
@@ -391,13 +391,11 @@
   if (sContent.IsEmpty())
     return ByteString();
 
-  std::ostringstream sAppStream;
-  sAppStream << "BT\n"
-             << GenerateColorAP(CFX_Color(CFX_Color::Type::kRGB, 0, 0, 0),
-                                PaintOperation::kFill)
-             << sContent << "ET\n"
-             << "Q\n";
-  return ByteString(sAppStream);
+  ByteString sColorAP = GenerateColorAP(
+      CFX_Color(CFX_Color::Type::kRGB, 0, 0, 0), PaintOperation::kFill);
+
+  return ByteString{"BT\n", sColorAP.AsStringView(), sContent.AsStringView(),
+                    "ET\n", "Q\n"};
 }
 
 RetainPtr<CPDF_Dictionary> GenerateResourceFontDict(