Fix nits with GetDecoderArray().
- Add using statement to shorten the return type to
Optional<DecoderArray>.
- Use pdfium::nullopt to clearly state the return type.
Change-Id: I748aefc1b9f625cba7ee1e6c2cf79af055eea184
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/67690
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index 7074061..be6a797 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -365,19 +365,18 @@
estimated_size, dest_buf, dest_size);
}
-Optional<std::vector<std::pair<ByteString, const CPDF_Object*>>>
-GetDecoderArray(const CPDF_Dictionary* pDict) {
+Optional<DecoderArray> GetDecoderArray(const CPDF_Dictionary* pDict) {
const CPDF_Object* pDecoder = pDict->GetDirectObjectFor("Filter");
if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName()))
- return {};
+ return pdfium::nullopt;
const CPDF_Object* pParams =
pDict->GetDirectObjectFor(pdfium::stream::kDecodeParms);
- std::vector<std::pair<ByteString, const CPDF_Object*>> decoder_array;
+ DecoderArray decoder_array;
if (const CPDF_Array* pDecoders = pDecoder->AsArray()) {
if (!ValidateDecoderPipeline(pDecoders))
- return {};
+ return pdfium::nullopt;
const CPDF_Array* pParamsArray = ToArray(pParams);
for (size_t i = 0; i < pDecoders->size(); ++i) {
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h
index ebb64e6..3134e7c 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.h
+++ b/core/fpdfapi/parser/fpdf_parser_decode.h
@@ -75,17 +75,16 @@
std::unique_ptr<uint8_t, FxFreeDeleter>* dest_buf,
uint32_t* dest_size);
-Optional<std::vector<std::pair<ByteString, const CPDF_Object*>>>
-GetDecoderArray(const CPDF_Dictionary* pDict);
+using DecoderArray = std::vector<std::pair<ByteString, const CPDF_Object*>>;
+Optional<DecoderArray> GetDecoderArray(const CPDF_Dictionary* pDict);
-bool PDF_DataDecode(
- pdfium::span<const uint8_t> src_span,
- uint32_t estimated_size,
- bool bImageAcc,
- const std::vector<std::pair<ByteString, const CPDF_Object*>>& decoder_array,
- std::unique_ptr<uint8_t, FxFreeDeleter>* dest_buf,
- uint32_t* dest_size,
- ByteString* ImageEncoding,
- RetainPtr<const CPDF_Dictionary>* pImageParams);
+bool PDF_DataDecode(pdfium::span<const uint8_t> src_span,
+ uint32_t estimated_size,
+ bool bImageAcc,
+ const DecoderArray& decoder_array,
+ std::unique_ptr<uint8_t, FxFreeDeleter>* dest_buf,
+ uint32_t* dest_size,
+ ByteString* ImageEncoding,
+ RetainPtr<const CPDF_Dictionary>* pImageParams);
#endif // CORE_FPDFAPI_PARSER_FPDF_PARSER_DECODE_H_