Return earlier in CPDF_TextPage::ProcessInsertObject() when possible.

Change-Id: Ibc446d9f4606d29f997ee3521f31f0fbcf1ad84b
Reviewed-on: https://pdfium-review.googlesource.com/32176
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 2daaea4..dae973b 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -1019,7 +1019,7 @@
           if (wstrItem.IsEmpty())
             wstrItem += (wchar_t)item.m_CharCode;
           wchar_t curChar = wstrItem[0];
-          if (curChar == 0x2D || curChar == 0xAD)
+          if (IsHyphenCode(curChar))
             return;
         }
         while (m_TempTextBuf.GetSize() > 0 &&
@@ -1340,16 +1340,20 @@
                              : GenerateCharacter::LineBreak;
   }
 
-  if (pObj->CountChars() == 1 && (0x2D == curChar || 0xAD == curChar) &&
-      IsHyphen(curChar)) {
+  if (pObj->CountChars() == 1 && IsHyphenCode(curChar) && IsHyphen(curChar))
     return GenerateCharacter::Hyphen;
-  }
+
+  if (curChar == L' ')
+    return GenerateCharacter::None;
+
   WideString PrevStr =
       m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevItem.m_CharCode);
   wchar_t preChar = PrevStr.Last();
+  if (preChar == L' ')
+    return GenerateCharacter::None;
+
   CFX_Matrix matrix = pObj->GetTextMatrix();
   matrix.Concat(formMatrix);
-
   float threshold2 = static_cast<float>(std::max(nLastWidth, nThisWidth));
   threshold2 = NormalizeThreshold(threshold2, 400, 700, 800);
   if (nLastWidth >= nThisWidth) {
@@ -1364,8 +1368,6 @@
       (threshold2 < 1.39001 && threshold2 > 1.38999)) {
     threshold2 *= 1.5;
   }
-  if (curChar == L' ' || preChar == L' ')
-    return GenerateCharacter::None;
   return GenerateSpace(pos, last_pos, this_width, last_width, threshold2)
              ? GenerateCharacter::Space
              : GenerateCharacter::None;