Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: core/src/fxcodec/jbig2/JBig2_Context.cpp

Issue 1761993002: Remove other remaining use of std::list::size() from loop body. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/src/fxcodec/jbig2/JBig2_Context.h" 7 #include "core/src/fxcodec/jbig2/JBig2_Context.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "core/src/fxcodec/jbig2/JBig2_ArithDecoder.h" 14 #include "core/src/fxcodec/jbig2/JBig2_ArithDecoder.h"
15 #include "core/src/fxcodec/jbig2/JBig2_BitStream.h" 15 #include "core/src/fxcodec/jbig2/JBig2_BitStream.h"
16 #include "core/src/fxcodec/jbig2/JBig2_GrdProc.h" 16 #include "core/src/fxcodec/jbig2/JBig2_GrdProc.h"
17 #include "core/src/fxcodec/jbig2/JBig2_GrrdProc.h" 17 #include "core/src/fxcodec/jbig2/JBig2_GrrdProc.h"
18 #include "core/src/fxcodec/jbig2/JBig2_HtrdProc.h" 18 #include "core/src/fxcodec/jbig2/JBig2_HtrdProc.h"
19 #include "core/src/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h" 19 #include "core/src/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h"
20 #include "core/src/fxcodec/jbig2/JBig2_PddProc.h" 20 #include "core/src/fxcodec/jbig2/JBig2_PddProc.h"
21 #include "core/src/fxcodec/jbig2/JBig2_SddProc.h" 21 #include "core/src/fxcodec/jbig2/JBig2_SddProc.h"
22 #include "core/src/fxcodec/jbig2/JBig2_TrdProc.h" 22 #include "core/src/fxcodec/jbig2/JBig2_TrdProc.h"
23 #include "third_party/base/stl_util.h"
23 24
24 namespace { 25 namespace {
25 26
26 size_t GetHuffContextSize(uint8_t val) { 27 size_t GetHuffContextSize(uint8_t val) {
27 return val == 0 ? 65536 : val == 1 ? 8192 : 1024; 28 return val == 0 ? 65536 : val == 1 ? 8192 : 1024;
28 } 29 }
29 30
30 size_t GetRefAggContextSize(FX_BOOL val) { 31 size_t GetRefAggContextSize(FX_BOOL val) {
31 return val ? 1024 : 8192; 32 return val ? 1024 : 8192;
32 } 33 }
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } else { 631 } else {
631 pSegment->m_Result.sd = pSymbolDictDecoder->decode_Huffman( 632 pSegment->m_Result.sd = pSymbolDictDecoder->decode_Huffman(
632 m_pStream.get(), &gbContext, &grContext, pPause); 633 m_pStream.get(), &gbContext, &grContext, pPause);
633 if (!pSegment->m_Result.sd) 634 if (!pSegment->m_Result.sd)
634 return JBIG2_ERROR_FATAL; 635 return JBIG2_ERROR_FATAL;
635 m_pStream->alignByte(); 636 m_pStream->alignByte();
636 } 637 }
637 if (m_bIsGlobal && kSymbolDictCacheMaxSize > 0) { 638 if (m_bIsGlobal && kSymbolDictCacheMaxSize > 0) {
638 std::unique_ptr<CJBig2_SymbolDict> value = 639 std::unique_ptr<CJBig2_SymbolDict> value =
639 pSegment->m_Result.sd->DeepCopy(); 640 pSegment->m_Result.sd->DeepCopy();
640 while (m_pSymbolDictCache->size() >= kSymbolDictCacheMaxSize) { 641 int size = pdfium::CollectionSize<int>(*m_pSymbolDictCache);
642 while (size >= kSymbolDictCacheMaxSize) {
641 delete m_pSymbolDictCache->back().second; 643 delete m_pSymbolDictCache->back().second;
642 m_pSymbolDictCache->pop_back(); 644 m_pSymbolDictCache->pop_back();
645 --size;
643 } 646 }
644 m_pSymbolDictCache->push_front(CJBig2_CachePair(key, value.release())); 647 m_pSymbolDictCache->push_front(CJBig2_CachePair(key, value.release()));
645 } 648 }
646 } 649 }
647 if (wFlags & 0x0200) { 650 if (wFlags & 0x0200) {
648 if (bUseGbContext) 651 if (bUseGbContext)
649 pSegment->m_Result.sd->SetGbContext(gbContext); 652 pSegment->m_Result.sd->SetGbContext(gbContext);
650 if (bUseGrContext) 653 if (bUseGrContext)
651 pSegment->m_Result.sd->SetGrContext(grContext); 654 pSegment->m_Result.sd->SetGrContext(grContext);
652 } 655 }
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 SBSYMCODES[CURTEMP].code = CURCODE; 1429 SBSYMCODES[CURTEMP].code = CURCODE;
1427 CURCODE = CURCODE + 1; 1430 CURCODE = CURCODE + 1;
1428 } 1431 }
1429 CURTEMP = CURTEMP + 1; 1432 CURTEMP = CURTEMP + 1;
1430 } 1433 }
1431 CURLEN = CURLEN + 1; 1434 CURLEN = CURLEN + 1;
1432 } 1435 }
1433 FX_Free(LENCOUNT); 1436 FX_Free(LENCOUNT);
1434 FX_Free(FIRSTCODE); 1437 FX_Free(FIRSTCODE);
1435 } 1438 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698