From f42d570492e881600d6b0692fb2fe0c0ec89e181 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 10 Aug 2018 20:50:52 +0000 Subject: Make CPDF_PSFunc::m_PS mutable. Preferred over const_cast<> to show how that state is used. Change-Id: Ia6fe6bf46fb7fa8e701481b1604073b5d7f222fa Reviewed-on: https://pdfium-review.googlesource.com/39870 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fpdfapi/page/cpdf_psfunc.cpp | 11 +++++------ core/fpdfapi/page/cpdf_psfunc.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_psfunc.cpp b/core/fpdfapi/page/cpdf_psfunc.cpp index be0afe9659..13d76aeb10 100644 --- a/core/fpdfapi/page/cpdf_psfunc.cpp +++ b/core/fpdfapi/page/cpdf_psfunc.cpp @@ -21,14 +21,13 @@ bool CPDF_PSFunc::v_Init(const CPDF_Object* pObj, } bool CPDF_PSFunc::v_Call(const float* inputs, float* results) const { - CPDF_PSEngine& PS = const_cast(m_PS); - PS.Reset(); + m_PS.Reset(); for (uint32_t i = 0; i < m_nInputs; i++) - PS.Push(inputs[i]); - PS.Execute(); - if (PS.GetStackSize() < m_nOutputs) + m_PS.Push(inputs[i]); + m_PS.Execute(); + if (m_PS.GetStackSize() < m_nOutputs) return false; for (uint32_t i = 0; i < m_nOutputs; i++) - results[m_nOutputs - i - 1] = PS.Pop(); + results[m_nOutputs - i - 1] = m_PS.Pop(); return true; } diff --git a/core/fpdfapi/page/cpdf_psfunc.h b/core/fpdfapi/page/cpdf_psfunc.h index 459da5a599..1274c21d50 100644 --- a/core/fpdfapi/page/cpdf_psfunc.h +++ b/core/fpdfapi/page/cpdf_psfunc.h @@ -25,7 +25,7 @@ class CPDF_PSFunc : public CPDF_Function { bool v_Call(const float* inputs, float* results) const override; private: - CPDF_PSEngine m_PS; + mutable CPDF_PSEngine m_PS; // Pre-initialized scratch space for v_Call(). }; #endif // CORE_FPDFAPI_PAGE_CPDF_PSFUNC_H_ -- cgit v1.2.3