summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-07-14 00:07:17 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-14 00:07:17 +0000
commitbfeb9343ee794a48b70c2f638c3d74f96e9afab2 (patch)
treec098d92551de16bf6fb23bb486cc0151c79c2340
parentcf403ba5720cf8bb05b6fbe9bf2b152c52e7e7b3 (diff)
downloadpdfium-bfeb9343ee794a48b70c2f638c3d74f96e9afab2.tar.xz
Use more ternary operators in content mark code.chromium/3493chromium/3492
Change-Id: Ibf09905523ae2d80ce48bfe7337733d8dc718669 Reviewed-on: https://pdfium-review.googlesource.com/37850 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
-rw-r--r--core/fpdfapi/page/cpdf_contentmark.cpp18
-rw-r--r--fpdfsdk/fpdf_editpage.cpp16
2 files changed, 7 insertions, 27 deletions
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> CPDF_ContentMark::Clone() {
auto result = pdfium::MakeUnique<CPDF_ContentMark>();
if (m_pMarkData)
- result->m_pMarkData.Reset(new MarkData(*m_pMarkData));
-
+ result->m_pMarkData = pdfium::MakeRetain<MarkData>(*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) {
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index 5a7312d9f3..ded55b9bef 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -100,13 +100,9 @@ void CalcBoundingBox(CPDF_PageObject* pPageObj) {
}
CPDF_Dictionary* GetMarkParamDict(FPDF_PAGEOBJECTMARK mark) {
- if (!mark)
- return nullptr;
-
CPDF_ContentMarkItem* pMarkItem =
CPDFContentMarkItemFromFPDFPageObjectMark(mark);
-
- return pMarkItem->GetParam();
+ return pMarkItem ? pMarkItem->GetParam() : nullptr;
}
CPDF_Dictionary* GetOrCreateMarkParamsDict(FPDF_DOCUMENT document,
@@ -365,10 +361,7 @@ FPDFPageObjMark_CountParams(FPDF_PAGEOBJECTMARK mark) {
CPDFContentMarkItemFromFPDFPageObjectMark(mark);
const CPDF_Dictionary* pParams = pMarkItem->GetParam();
- if (!pParams)
- return 0;
-
- return pParams->GetCount();
+ return pParams ? pParams->GetCount() : 0;
}
FPDF_EXPORT unsigned long FPDF_CALLCONV
@@ -399,10 +392,7 @@ FPDFPageObjMark_GetParamValueType(FPDF_PAGEOBJECTMARK mark,
return FPDF_OBJECT_UNKNOWN;
const CPDF_Object* pObject = pParams->GetObjectFor(key);
- if (!pObject)
- return FPDF_OBJECT_UNKNOWN;
-
- return pObject->GetType();
+ return pObject ? pObject->GetType() : FPDF_OBJECT_UNKNOWN;
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV