summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-21 11:28:02 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-21 11:28:02 -0700
commitca612c1f9c47fae74dda493291d52ec27eff4a7b (patch)
treef41ea43a7e612ad1e05409d71931ab475907e15d
parent334319477703b5ba136373c4e3598e9a56e7f081 (diff)
downloadpdfium-ca612c1f9c47fae74dda493291d52ec27eff4a7b.tar.xz
Remove CFX_ArrayTemplate from fpdf_parser_decode.cpp
Replace two parallel arrays with single array of pairs. Review URL: https://codereview.chromium.org/1911673002
-rw-r--r--core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp26
1 files 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 <limits.h>
+#include <utility>
#include <vector>
#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<CFX_ByteString> DecoderList;
- CFX_ArrayTemplate<CPDF_Object*> ParamList;
+
+ std::vector<std::pair<CFX_ByteString, CPDF_Object*>> 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<uint8_t*>(src_buf);
uint32_t last_size = src_size;
- int nSize = pdfium::CollectionSize<int>(DecoderList);
+ int nSize = pdfium::CollectionSize<int>(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;