From aa987a9a895d42749c0f5e4092618fe7ded6667e Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 16 Aug 2018 20:51:08 +0000 Subject: Remove default arg from CFX_BinaryBuf::EstimateSize(). Disentangle setting an allocation step from estimating size, these separate concepts can be handled separately. Change-Id: I27bf3e193018a4377ccf266207b889fdb672826c Reviewed-on: https://pdfium-review.googlesource.com/40210 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fxcrt/cfx_binarybuf.cpp | 6 ++---- core/fxcrt/cfx_binarybuf.h | 9 +++++---- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'core/fxcrt') diff --git a/core/fxcrt/cfx_binarybuf.cpp b/core/fxcrt/cfx_binarybuf.cpp index 5ef907cb80..67aa29263b 100644 --- a/core/fxcrt/cfx_binarybuf.cpp +++ b/core/fxcrt/cfx_binarybuf.cpp @@ -9,8 +9,7 @@ #include #include -CFX_BinaryBuf::CFX_BinaryBuf() - : m_AllocStep(0), m_AllocSize(0), m_DataSize(0) {} +CFX_BinaryBuf::CFX_BinaryBuf() = default; CFX_BinaryBuf::~CFX_BinaryBuf() = default; @@ -37,8 +36,7 @@ std::unique_ptr CFX_BinaryBuf::DetachBuffer() { return std::move(m_pBuffer); } -void CFX_BinaryBuf::EstimateSize(size_t size, size_t step) { - m_AllocStep = step; +void CFX_BinaryBuf::EstimateSize(size_t size) { if (m_AllocSize < size) ExpandBuf(size - m_DataSize); } diff --git a/core/fxcrt/cfx_binarybuf.h b/core/fxcrt/cfx_binarybuf.h index 2d4f019560..b519d57e10 100644 --- a/core/fxcrt/cfx_binarybuf.h +++ b/core/fxcrt/cfx_binarybuf.h @@ -24,7 +24,8 @@ class CFX_BinaryBuf { bool IsEmpty() const { return GetLength() == 0; } void Clear(); - void EstimateSize(size_t size, size_t alloc_step = 0); + void SetAllocStep(size_t step) { m_AllocStep = step; } + void EstimateSize(size_t size); void AppendBlock(const void* pBuf, size_t size); void AppendString(const ByteString& str) { AppendBlock(str.c_str(), str.GetLength()); @@ -43,9 +44,9 @@ class CFX_BinaryBuf { protected: void ExpandBuf(size_t size); - size_t m_AllocStep; - size_t m_AllocSize; - size_t m_DataSize; + size_t m_AllocStep = 0; + size_t m_AllocSize = 0; + size_t m_DataSize = 0; std::unique_ptr m_pBuffer; }; -- cgit v1.2.3