From ca612c1f9c47fae74dda493291d52ec27eff4a7b Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 21 Apr 2016 11:28:02 -0700 Subject: Remove CFX_ArrayTemplate from fpdf_parser_decode.cpp Replace two parallel arrays with single array of pairs. Review URL: https://codereview.chromium.org/1911673002 --- core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp | 26 ++++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp index 5f8d425b96..3893d9bd41 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp @@ -7,6 +7,7 @@ #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include +#include #include #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" @@ -342,29 +343,26 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf, CPDF_Object* pParams = pDict ? pDict->GetDirectObjectBy("DecodeParms") : nullptr; - std::vector DecoderList; - CFX_ArrayTemplate ParamList; + + std::vector> DecoderArray; if (CPDF_Array* pDecoders = pDecoder->AsArray()) { CPDF_Array* pParamsArray = ToArray(pParams); - if (!pParamsArray) - pParams = nullptr; - for (size_t i = 0; i < pDecoders->GetCount(); i++) { - DecoderList.push_back(pDecoders->GetStringAt(i)); - ParamList.Add(pParams ? pParamsArray->GetDictAt(i) : nullptr); + DecoderArray.push_back( + {pDecoders->GetStringAt(i), + pParamsArray ? pParamsArray->GetDictAt(i) : nullptr}); } } else { - DecoderList.push_back(pDecoder->GetString()); - ParamList.Add(pParams ? pParams->GetDict() : nullptr); + DecoderArray.push_back( + {pDecoder->GetString(), pParams ? pParams->GetDict() : nullptr}); } - uint8_t* last_buf = (uint8_t*)src_buf; + uint8_t* last_buf = const_cast(src_buf); uint32_t last_size = src_size; - int nSize = pdfium::CollectionSize(DecoderList); + int nSize = pdfium::CollectionSize(DecoderArray); for (int i = 0; i < nSize; i++) { int estimated_size = i == nSize - 1 ? last_estimated_size : 0; - CFX_ByteString decoder = DecoderList[i]; - // Use ToDictionary here because we can push nullptr into the ParamList. - CPDF_Dictionary* pParam = ToDictionary(ParamList[i]); + CFX_ByteString decoder = DecoderArray[i].first; + CPDF_Dictionary* pParam = ToDictionary(DecoderArray[i].second); uint8_t* new_buf = nullptr; uint32_t new_size = (uint32_t)-1; int offset = -1; -- cgit v1.2.3