From d8882193737ae167a33c1bf7a5cdb64543ad0301 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Wed, 11 Jul 2018 22:35:59 +0000 Subject: Inline GetMarkParamPairAtIndex into FPDFPageObjMark_GetParamKey. Bug: pdfium:1037 Change-Id: Iddc0d51874cf22d24ddf634ff767cd08807a4904 Reviewed-on: https://pdfium-review.googlesource.com/37630 Commit-Queue: Henrique Nakashima Reviewed-by: Lei Zhang --- fpdfsdk/fpdf_editpage.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp index 2ace03cccd..4df5505cca 100644 --- a/fpdfsdk/fpdf_editpage.cpp +++ b/fpdfsdk/fpdf_editpage.cpp @@ -109,22 +109,6 @@ const CPDF_Dictionary* GetMarkParamDict(FPDF_PAGEOBJECTMARK mark) { return pMarkItem->GetParam(); } -const std::pair>* -GetMarkParamPairAtIndex(FPDF_PAGEOBJECTMARK mark, unsigned long index) { - const CPDF_Dictionary* pParams = GetMarkParamDict(mark); - if (!pParams) - return nullptr; - - for (auto& it : *pParams) { - if (index == 0) - return ⁢ - - --index; - } - - return nullptr; -} - CPDF_Dictionary* GetOrCreateMarkParamsDict(FPDF_DOCUMENT document, FPDF_PAGEOBJECTMARK mark) { CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); @@ -367,12 +351,19 @@ FPDFPageObjMark_GetParamKey(FPDF_PAGEOBJECTMARK mark, unsigned long index, void* buffer, unsigned long buflen) { - auto* param_pair = GetMarkParamPairAtIndex(mark, index); - if (!param_pair) + const CPDF_Dictionary* pParams = GetMarkParamDict(mark); + if (!pParams) return 0; - return Utf16EncodeMaybeCopyAndReturnLength( - WideString::FromUTF8(param_pair->first.AsStringView()), buffer, buflen); + for (auto& it : *pParams) { + if (index == 0) { + return Utf16EncodeMaybeCopyAndReturnLength( + WideString::FromUTF8(it.first.AsStringView()), buffer, buflen); + } + --index; + } + + return 0; } FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV -- cgit v1.2.3