Remove unique_ptr<> to std::set<> as possible.

Sets are small if we were to move-assign them, but we don't
even do that, nor do we rely on nullptr as an overload for a
no-value case.

Change-Id: I98715f4109dd48f4c6fb163f595cc5e8c2115aca
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/78750
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 8dc8ca2..ff86567 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -185,12 +185,12 @@
 
 CPDF_ContentParser::Stage CPDF_ContentParser::Parse() {
   if (!m_pParser) {
-    m_pParsedSet = std::make_unique<std::set<const uint8_t*>>();
+    m_ParsedSet.clear();
     m_pParser = std::make_unique<CPDF_StreamContentParser>(
         m_pObjectHolder->GetDocument(), m_pObjectHolder->m_pPageResources.Get(),
         nullptr, nullptr, m_pObjectHolder.Get(),
         m_pObjectHolder->m_pResources.Get(), m_pObjectHolder->GetBBox(),
-        nullptr, m_pParsedSet.get());
+        nullptr, &m_ParsedSet);
     m_pParser->GetCurStates()->m_ColorState.SetDefault();
   }
   if (m_CurrentOffset >= m_Size)
diff --git a/core/fpdfapi/page/cpdf_contentparser.h b/core/fpdfapi/page/cpdf_contentparser.h
index 2f9a44b..7d99da8 100644
--- a/core/fpdfapi/page/cpdf_contentparser.h
+++ b/core/fpdfapi/page/cpdf_contentparser.h
@@ -70,12 +70,9 @@
   uint32_t m_nStreams = 0;
   uint32_t m_Size = 0;
   uint32_t m_CurrentOffset = 0;
+  std::set<const uint8_t*> m_ParsedSet;  // Only used when parsing pages.
 
-  // Only used when parsing pages.
-  std::unique_ptr<std::set<const uint8_t*>> m_pParsedSet;
-
-  // |m_pParser| has a reference to |m_pParsedSet|, so must be below and thus
-  // destroyed first.
+  // Must outlive |m_pParsedSet|.
   std::unique_ptr<CPDF_StreamContentParser> m_pParser;
 };
 
diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp
index 239079e..d15c7e4 100644
--- a/core/fpdfapi/page/cpdf_form.cpp
+++ b/core/fpdfapi/page/cpdf_form.cpp
@@ -71,15 +71,10 @@
     return;
 
   if (GetParseState() == ParseState::kNotParsed) {
-    if (!pParsedSet) {
-      if (!m_ParsedSet)
-        m_ParsedSet = std::make_unique<std::set<const uint8_t*>>();
-      pParsedSet = m_ParsedSet.get();
-    }
     StartParse(std::make_unique<CPDF_ContentParser>(
-        this, pGraphicStates, pParentMatrix, pType3Char, pParsedSet));
+        this, pGraphicStates, pParentMatrix, pType3Char,
+        pParsedSet ? pParsedSet : &m_ParsedSet));
   }
-
   DCHECK(GetParseState() == ParseState::kParsing);
   ContinueParse(nullptr);
 }
diff --git a/core/fpdfapi/page/cpdf_form.h b/core/fpdfapi/page/cpdf_form.h
index e8b9d1f..6f571a2 100644
--- a/core/fpdfapi/page/cpdf_form.h
+++ b/core/fpdfapi/page/cpdf_form.h
@@ -7,12 +7,12 @@
 #ifndef CORE_FPDFAPI_PAGE_CPDF_FORM_H_
 #define CORE_FPDFAPI_PAGE_CPDF_FORM_H_
 
-#include <memory>
 #include <set>
 #include <utility>
 
 #include "core/fpdfapi/font/cpdf_font.h"
 #include "core/fpdfapi/page/cpdf_pageobjectholder.h"
+#include "core/fxcrt/retain_ptr.h"
 
 class CFX_Matrix;
 class CPDF_AllStates;
@@ -59,7 +59,7 @@
                             CPDF_Type3Char* pType3Char,
                             std::set<const uint8_t*>* pParsedSet);
 
-  std::unique_ptr<std::set<const uint8_t*>> m_ParsedSet;
+  std::set<const uint8_t*> m_ParsedSet;
   RetainPtr<CPDF_Stream> const m_pFormStream;
 };