Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1241)

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp

Issue 1243883003: Fix else-after-returns throughout pdfium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, Address comments. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
index a3e409df5715cfe6c7961b313c7425fd5396df4a..c7d1dece250c14924b5f5c9894cdf13b4dc1a5be 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
@@ -160,8 +160,8 @@ CPDF_Array* CPDF_Object::GetArray() const
{
if (m_Type == PDFOBJ_ARRAY)
return (CPDF_Array*)this;
- else
- return NULL;
+
+ return NULL;
}
void CPDF_Object::SetString(const CFX_ByteString& str)
{
@@ -201,7 +201,8 @@ FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const
if (pOther->m_Type != m_Type) {
if (m_Type == PDFOBJ_REFERENCE && GetDirect()) {
return GetDirect()->IsIdentical(pOther);
- } else if (pOther->m_Type == PDFOBJ_REFERENCE) {
+ }
+ if (pOther->m_Type == PDFOBJ_REFERENCE) {
return IsIdentical(pOther->GetDirect());
}
return FALSE;
@@ -285,27 +286,22 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visite
CPDF_StreamAcc acc;
acc.LoadAllData(pThis, TRUE);
FX_DWORD streamSize = acc.GetSize();
- CPDF_Stream* pObj;
- if (pThis->GetDict())
- pObj = new CPDF_Stream(acc.DetachData(), streamSize, (CPDF_Dictionary*)((CPDF_Object*)pThis->GetDict())->CloneInternal(bDirect, visited));
- else
- pObj = new CPDF_Stream(acc.DetachData(), streamSize, NULL);
- return pObj;
+ CPDF_Dictionary* pDict = pThis->GetDict();
+ if (pDict)
+ pDict = (CPDF_Dictionary*)((CPDF_Object*)pDict)->CloneInternal(bDirect, visited);
+ return new CPDF_Stream(acc.DetachData(), streamSize, pDict);
}
case PDFOBJ_REFERENCE: {
CPDF_Reference* pRef = (CPDF_Reference*)this;
FX_DWORD obj_num = pRef->m_RefObjNum;
if (bDirect && !visited->GetValueAt((void*)(uintptr_t)obj_num)) {
visited->SetAt((void*)(uintptr_t)obj_num, (void*)1);
- CPDF_Object* ret;
- if (pRef->GetDirect())
- ret = pRef->GetDirect()->CloneInternal(TRUE, visited);
- else
- ret = NULL;
- return ret;
- } else {
- return new CPDF_Reference(pRef->m_pObjList, obj_num);
+ if (!pRef->GetDirect())
+ return nullptr;
+
+ return pRef->GetDirect()->CloneInternal(TRUE, visited);
}
+ return new CPDF_Reference(pRef->m_pObjList, obj_num);
}
}
return NULL;
@@ -321,12 +317,14 @@ CFX_WideString CPDF_Object::GetUnicodeText(CFX_CharMap* pCharMap) const
{
if (m_Type == PDFOBJ_STRING) {
return PDF_DecodeText(((CPDF_String*)this)->m_String, pCharMap);
- } else if (m_Type == PDFOBJ_STREAM) {
+ }
+ if (m_Type == PDFOBJ_STREAM) {
CPDF_StreamAcc stream;
stream.LoadAllData((CPDF_Stream*)this, FALSE);
CFX_WideString result = PDF_DecodeText(stream.GetData(), stream.GetSize(), pCharMap);
return result;
- } else if (m_Type == PDFOBJ_NAME) {
+ }
+ if (m_Type == PDFOBJ_NAME) {
return PDF_DecodeText(((CPDF_Name*)this)->m_Name, pCharMap);
}
return CFX_WideString();
@@ -427,8 +425,7 @@ CFX_ByteString CPDF_Array::GetString(FX_DWORD i) const
CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i);
return p->GetString();
}
- else
- return CFX_ByteString();
+ return CFX_ByteString();
}
CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const
{
@@ -436,8 +433,7 @@ CFX_ByteStringC CPDF_Array::GetConstString(FX_DWORD i) const
CPDF_Object* p = (CPDF_Object*)m_Objects.GetAt(i);
return p->GetConstString();
}
- else
- return CFX_ByteStringC();
+ return CFX_ByteStringC();
}
int CPDF_Array::GetInteger(FX_DWORD i) const
{
@@ -458,11 +454,13 @@ FX_FLOAT CPDF_Array::GetNumber(FX_DWORD i) const
CPDF_Dictionary* CPDF_Array::GetDict(FX_DWORD i) const
{
CPDF_Object* p = GetElementValue(i);
- if (p == NULL) {
+ if (!p) {
return NULL;
- } else if (p->GetType() == PDFOBJ_DICTIONARY) {
+ }
+ if (p->GetType() == PDFOBJ_DICTIONARY) {
return (CPDF_Dictionary*)p;
- } else if (p->GetType() == PDFOBJ_STREAM) {
+ }
+ if (p->GetType() == PDFOBJ_STREAM) {
return ((CPDF_Stream*)p)->GetDict();
}
return NULL;
@@ -604,19 +602,19 @@ CFX_ByteString CPDF_Dictionary::GetString(const CFX_ByteStringC& key) const
{
CPDF_Object* p = NULL;
m_Map.Lookup(key, (void*&)p);
- if (p)
+ if (p) {
return p->GetString();
- else
- return CFX_ByteString();
+ }
+ return CFX_ByteString();
}
CFX_ByteStringC CPDF_Dictionary::GetConstString(const CFX_ByteStringC& key) const
{
CPDF_Object* p = NULL;
m_Map.Lookup(key, (void*&)p);
- if (p)
+ if (p) {
return p->GetConstString();
- else
- return CFX_ByteStringC();
+ }
+ return CFX_ByteStringC();
}
CFX_WideString CPDF_Dictionary::GetUnicodeText(const CFX_ByteStringC& key, CFX_CharMap* pCharMap) const
{
@@ -647,10 +645,10 @@ CFX_ByteStringC CPDF_Dictionary::GetConstString(const CFX_ByteStringC& key, cons
{
CPDF_Object* p = NULL;
m_Map.Lookup(key, (void*&)p);
- if (p)
+ if (p) {
return p->GetConstString();
- else
- return CFX_ByteStringC(def);
+ }
+ return CFX_ByteStringC(def);
}
int CPDF_Dictionary::GetInteger(const CFX_ByteStringC& key) const
{
@@ -691,14 +689,16 @@ FX_BOOL CPDF_Dictionary::GetBoolean(const CFX_ByteStringC& key, FX_BOOL bDefault
CPDF_Dictionary* CPDF_Dictionary::GetDict(const CFX_ByteStringC& key) const
{
CPDF_Object* p = GetElementValue(key);
- if (p == NULL) {
- return NULL;
- } else if (p->GetType() == PDFOBJ_DICTIONARY) {
+ if (!p) {
+ return nullptr;
+ }
+ if (p->GetType() == PDFOBJ_DICTIONARY) {
return (CPDF_Dictionary*)p;
- } else if (p->GetType() == PDFOBJ_STREAM) {
+ }
+ if (p->GetType() == PDFOBJ_STREAM) {
return ((CPDF_Stream*)p)->GetDict();
}
- return NULL;
+ return nullptr;
}
CPDF_Array* CPDF_Dictionary::GetArray(const CFX_ByteStringC& key) const
{
@@ -1269,12 +1269,11 @@ void CPDF_IndirectObjects::InsertIndirectObject(FX_DWORD objnum, CPDF_Object* pO
}
void* value = NULL;
if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) {
- if (value)
- {
- if (pObj->GetGenNum() <= ((CPDF_Object*)value)->GetGenNum())
+ if (value) {
+ if (pObj->GetGenNum() <= ((CPDF_Object*)value)->GetGenNum()) {
return;
- else
- ((CPDF_Object*)value)->Destroy();
+ }
+ ((CPDF_Object*)value)->Destroy();
}
}
pObj->m_ObjNum = objnum;
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698