Avoid stringstreams in cpwl_edit_impl.

Merely aggregate byte strings, which avoids copying from a
string stream to a byte string for drawing.

-- kill some blank lines

Change-Id: I39d96e67ec37c77db215287fafaced881d8d620b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/88933
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.cpp b/fpdfsdk/pwl/cpwl_edit_impl.cpp
index 287cbe1..b953f41 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_impl.cpp
@@ -8,7 +8,6 @@
 
 #include <algorithm>
 #include <memory>
-#include <sstream>
 #include <utility>
 
 #include "core/fpdfapi/font/cpdf_font.h"
@@ -596,7 +595,6 @@
   const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255);
   const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113);
 
-  std::ostringstream sTextBuf;
   int32_t nFontIndex = -1;
   CFX_PointF ptBT;
   CFX_RenderDevice::StateRestorer restorer(pDevice);
@@ -613,6 +611,7 @@
   else
     pIterator->SetAt(0);
 
+  ByteString sTextBuf;
   CPVT_WordPlace oldplace;
   while (pIterator->NextWord()) {
     CPVT_WordPlace place = pIterator->GetAt();
@@ -632,7 +631,6 @@
       if (bSelect) {
         CPVT_Line line;
         pIterator->GetLine(line);
-
         if (pSystemHandler->IsSelectionImplemented()) {
           CFX_FloatRect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent,
                            word.ptWord.x + word.fWidth,
@@ -649,24 +647,21 @@
                             CFX_FillRenderOptions::WindingOptions());
         }
       }
-
       if (bContinuous) {
         if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex ||
             crOldFill != crCurFill) {
-          if (sTextBuf.tellp() > 0) {
+          if (!sTextBuf.IsEmpty()) {
             DrawTextString(pDevice,
                            CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
                            pFontMap->GetPDFFont(nFontIndex).Get(), fFontSize,
-                           mtUser2Device, ByteString(sTextBuf), crOldFill);
-
-            sTextBuf.str("");
+                           mtUser2Device, sTextBuf, crOldFill);
+            sTextBuf.clear();
           }
           nFontIndex = word.nFontIndex;
           ptBT = word.ptWord;
           crOldFill = crCurFill;
         }
-
-        sTextBuf << GetPDFWordString(word.nFontIndex, word.Word, SubWord);
+        sTextBuf += GetPDFWordString(word.nFontIndex, word.Word, SubWord);
       } else {
         DrawTextString(
             pDevice,
@@ -678,12 +673,11 @@
       oldplace = place;
     }
   }
-
-  if (sTextBuf.tellp() > 0) {
+  if (!sTextBuf.IsEmpty()) {
     DrawTextString(pDevice,
                    CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
                    pFontMap->GetPDFFont(nFontIndex).Get(), fFontSize,
-                   mtUser2Device, ByteString(sTextBuf), crOldFill);
+                   mtUser2Device, sTextBuf, crOldFill);
   }
 }