From 9cc00f40a38c9b2beed17ecfe0e5f71c127d2ea4 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 28 Nov 2017 19:22:47 +0000 Subject: Remove CollectionSize from JBig2_Context Bug: pdfium:774 Change-Id: Ie7674ac55dea6284a0d974cef107ef357197a06b Reviewed-on: https://pdfium-review.googlesource.com/19610 Commit-Queue: dsinclair Reviewed-by: Ryan Harrison --- core/fxcodec/jbig2/JBig2_Context.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp index f4be12e889..30e4aab78c 100644 --- a/core/fxcodec/jbig2/JBig2_Context.cpp +++ b/core/fxcodec/jbig2/JBig2_Context.cpp @@ -25,7 +25,6 @@ #include "core/fxcodec/jbig2/JBig2_TrdProc.h" #include "core/fxcrt/ifx_pauseindicator.h" #include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" namespace { @@ -46,7 +45,9 @@ size_t GetRefAggContextSize(bool val) { // list keeps track of the freshness of entries, with freshest ones // at the front. Even a tiny cache size like 2 makes a dramatic // difference for typical JBIG2 documents. -static const int kSymbolDictCacheMaxSize = 2; +static const size_t kSymbolDictCacheMaxSize = 2; +static_assert(kSymbolDictCacheMaxSize > 0, + "Symbol Dictionary Cache must have non-zero size"); CJBig2_Context::CJBig2_Context(const RetainPtr& pGlobalStream, const RetainPtr& pSrcStream, @@ -611,7 +612,7 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment) { if (m_bIsGlobal) { std::unique_ptr value = pSegment->m_SymbolDict->DeepCopy(); - int size = pdfium::CollectionSize(*m_pSymbolDictCache); + size_t size = m_pSymbolDictCache->size(); while (size >= kSymbolDictCacheMaxSize) { m_pSymbolDictCache->pop_back(); --size; -- cgit v1.2.3