From bfeb9343ee794a48b70c2f638c3d74f96e9afab2 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Sat, 14 Jul 2018 00:07:17 +0000 Subject: Use more ternary operators in content mark code. Change-Id: Ibf09905523ae2d80ce48bfe7337733d8dc718669 Reviewed-on: https://pdfium-review.googlesource.com/37850 Commit-Queue: Henrique Nakashima Reviewed-by: Henrique Nakashima --- core/fpdfapi/page/cpdf_contentmark.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp index 615d31f3eb..13945d9337 100644 --- a/core/fpdfapi/page/cpdf_contentmark.cpp +++ b/core/fpdfapi/page/cpdf_contentmark.cpp @@ -18,23 +18,16 @@ CPDF_ContentMark::~CPDF_ContentMark() {} std::unique_ptr CPDF_ContentMark::Clone() { auto result = pdfium::MakeUnique(); if (m_pMarkData) - result->m_pMarkData.Reset(new MarkData(*m_pMarkData)); - + result->m_pMarkData = pdfium::MakeRetain(*m_pMarkData); return result; } size_t CPDF_ContentMark::CountItems() const { - if (!m_pMarkData) - return 0; - - return m_pMarkData->CountItems(); + return m_pMarkData ? m_pMarkData->CountItems() : 0; } bool CPDF_ContentMark::ContainsItem(const CPDF_ContentMarkItem* pItem) const { - if (!m_pMarkData) - return false; - - return m_pMarkData->ContainsItem(pItem); + return m_pMarkData && m_pMarkData->ContainsItem(pItem); } CPDF_ContentMarkItem* CPDF_ContentMark::GetItem(size_t i) { @@ -48,10 +41,7 @@ const CPDF_ContentMarkItem* CPDF_ContentMark::GetItem(size_t i) const { } int CPDF_ContentMark::GetMarkedContentID() const { - if (!m_pMarkData) - return -1; - - return m_pMarkData->GetMarkedContentID(); + return m_pMarkData ? m_pMarkData->GetMarkedContentID() : -1; } void CPDF_ContentMark::AddMark(ByteString name) { -- cgit v1.2.3