Remove unused member CFX_CSSStyleSheet:m_StringCache
-- Remove Reset() method and inline the one place it is required.
-- No need to pass address of member to helper method.
Change-Id: I59916640ef78c6d103fcd46adb769e2890338877
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/66513
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/css/cfx_cssstylesheet.cpp b/core/fxcrt/css/cfx_cssstylesheet.cpp
index a4f3dc8..cb2d58a 100644
--- a/core/fxcrt/css/cfx_cssstylesheet.cpp
+++ b/core/fxcrt/css/cfx_cssstylesheet.cpp
@@ -16,14 +16,7 @@
CFX_CSSStyleSheet::CFX_CSSStyleSheet() {}
-CFX_CSSStyleSheet::~CFX_CSSStyleSheet() {
- Reset();
-}
-
-void CFX_CSSStyleSheet::Reset() {
- m_RuleArray.clear();
- m_StringCache.clear();
-}
+CFX_CSSStyleSheet::~CFX_CSSStyleSheet() = default;
size_t CFX_CSSStyleSheet::CountRules() const {
return m_RuleArray.size();
@@ -36,26 +29,24 @@
bool CFX_CSSStyleSheet::LoadBuffer(const wchar_t* pBuffer, int32_t iBufSize) {
ASSERT(pBuffer);
+ m_RuleArray.clear();
auto pSyntax = pdfium::MakeUnique<CFX_CSSSyntaxParser>(pBuffer, iBufSize);
- Reset();
CFX_CSSSyntaxStatus eStatus;
do {
switch (eStatus = pSyntax->DoSyntaxParse()) {
case CFX_CSSSyntaxStatus::kStyleRule:
- eStatus = LoadStyleRule(pSyntax.get(), &m_RuleArray);
+ eStatus = LoadStyleRule(pSyntax.get());
break;
default:
break;
}
} while (eStatus >= CFX_CSSSyntaxStatus::kNone);
- m_StringCache.clear();
return eStatus != CFX_CSSSyntaxStatus::kError;
}
CFX_CSSSyntaxStatus CFX_CSSStyleSheet::LoadStyleRule(
- CFX_CSSSyntaxParser* pSyntax,
- std::vector<std::unique_ptr<CFX_CSSStyleRule>>* ruleArray) {
+ CFX_CSSSyntaxParser* pSyntax) {
std::vector<std::unique_ptr<CFX_CSSSelector>> selectors;
CFX_CSSStyleRule* pStyleRule = nullptr;
@@ -97,7 +88,7 @@
auto rule = pdfium::MakeUnique<CFX_CSSStyleRule>();
pStyleRule = rule.get();
pStyleRule->SetSelector(&selectors);
- ruleArray->push_back(std::move(rule));
+ m_RuleArray.push_back(std::move(rule));
} else {
SkipRuleSet(pSyntax);
return CFX_CSSSyntaxStatus::kNone;
@@ -106,7 +97,7 @@
}
case CFX_CSSSyntaxStatus::kDeclClose: {
if (pStyleRule && pStyleRule->GetDeclaration()->empty()) {
- ruleArray->pop_back();
+ m_RuleArray.pop_back();
pStyleRule = nullptr;
}
return CFX_CSSSyntaxStatus::kNone;
diff --git a/core/fxcrt/css/cfx_cssstylesheet.h b/core/fxcrt/css/cfx_cssstylesheet.h
index ed89106..a99353a 100644
--- a/core/fxcrt/css/cfx_cssstylesheet.h
+++ b/core/fxcrt/css/cfx_cssstylesheet.h
@@ -7,7 +7,6 @@
#ifndef CORE_FXCRT_CSS_CFX_CSSSTYLESHEET_H_
#define CORE_FXCRT_CSS_CFX_CSSSTYLESHEET_H_
-#include <map>
#include <memory>
#include <vector>
@@ -22,19 +21,14 @@
~CFX_CSSStyleSheet();
bool LoadBuffer(const wchar_t* pBuffer, int32_t iBufSize);
-
size_t CountRules() const;
CFX_CSSStyleRule* GetRule(size_t index) const;
private:
- void Reset();
- CFX_CSSSyntaxStatus LoadStyleRule(
- CFX_CSSSyntaxParser* pSyntax,
- std::vector<std::unique_ptr<CFX_CSSStyleRule>>* ruleArray);
+ CFX_CSSSyntaxStatus LoadStyleRule(CFX_CSSSyntaxParser* pSyntax);
void SkipRuleSet(CFX_CSSSyntaxParser* pSyntax);
std::vector<std::unique_ptr<CFX_CSSStyleRule>> m_RuleArray;
- std::map<uint32_t, wchar_t*> m_StringCache;
};
#endif // CORE_FXCRT_CSS_CFX_CSSSTYLESHEET_H_