From 5bedb078f157108604e466c14b05536a100de19b Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 9 Feb 2017 15:31:35 +0100 Subject: [PATCH] Bug 1338086 - Remove useless else blocks in order to reduce complexity in xpcom/ r=froydnj MozReview-Commit-ID: JUJARn5Nspp --HG-- extra : rebase_source : c719d19215fb26ace822269c2a28faf5cf35ffbb --- xpcom/build/FileLocation.cpp | 4 +-- xpcom/glue/nsStringAPI.cpp | 12 ++++--- xpcom/io/nsLocalFileUnix.cpp | 33 +++++++++---------- .../md/unix/xptcstubs_x86_64_linux.cpp | 18 +++++----- 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/xpcom/build/FileLocation.cpp b/xpcom/build/FileLocation.cpp index bd6b663c887e..af2f38105baf 100644 --- a/xpcom/build/FileLocation.cpp +++ b/xpcom/build/FileLocation.cpp @@ -182,7 +182,7 @@ FileLocation::Data::GetSize(uint32_t* aResult) *aResult = fileInfo.size; return NS_OK; } - else if (mItem) { + if (mItem) { *aResult = mItem->RealSize(); return NS_OK; } @@ -203,7 +203,7 @@ FileLocation::Data::Copy(char* aBuf, uint32_t aLen) } return NS_OK; } - else if (mItem) { + if (mItem) { nsZipCursor cursor(mItem, mZip, reinterpret_cast(aBuf), aLen, true); uint32_t readLen; diff --git a/xpcom/glue/nsStringAPI.cpp b/xpcom/glue/nsStringAPI.cpp index e5114a149a81..6fd21fcece06 100644 --- a/xpcom/glue/nsStringAPI.cpp +++ b/xpcom/glue/nsStringAPI.cpp @@ -219,7 +219,8 @@ nsAString::Compare(const char_type* aOther, ComparatorFunc aComparator) const if (result == 0) { if (selflen < otherlen) { return -1; - } else if (selflen > otherlen) { + } + if (selflen > otherlen) { return 1; } } @@ -239,7 +240,8 @@ nsAString::Compare(const self_type& aOther, ComparatorFunc aComparator) const if (result == 0) { if (selflen < otherlen) { return -1; - } else if (selflen > otherlen) { + } + if (selflen > otherlen) { return 1; } } @@ -758,7 +760,8 @@ nsACString::Compare(const char_type* aOther, ComparatorFunc aComparator) const if (result == 0) { if (selflen < otherlen) { return -1; - } else if (selflen > otherlen) { + } + if (selflen > otherlen) { return 1; } } @@ -778,7 +781,8 @@ nsACString::Compare(const self_type& aOther, ComparatorFunc aComparator) const if (result == 0) { if (selflen < otherlen) { return -1; - } else if (selflen > otherlen) { + } + if (selflen > otherlen) { return 1; } } diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index 6f13e2a7da27..ae6d0140cd60 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -961,13 +961,12 @@ nsLocalFile::CopyToNative(nsIFile* aNewParent, const nsACString& aNewName) if (bytesRead < 0) { if (saved_write_error != NS_OK) { return saved_write_error; - } else if (saved_read_error != NS_OK) { + } + if (saved_read_error != NS_OK) { return saved_read_error; } #if DEBUG - else { // sanity check. Die and debug. - MOZ_ASSERT(0); - } + MOZ_ASSERT(0); #endif } @@ -1965,20 +1964,20 @@ nsLocalFile::Reveal() if (isDirectory) { return giovfs->ShowURIForInput(mPath); - } else if (NS_SUCCEEDED(giovfs->OrgFreedesktopFileManager1ShowItems(mPath))) { - return NS_OK; - } else { - nsCOMPtr parentDir; - nsAutoCString dirPath; - if (NS_FAILED(GetParent(getter_AddRefs(parentDir)))) { - return NS_ERROR_FAILURE; - } - if (NS_FAILED(parentDir->GetNativePath(dirPath))) { - return NS_ERROR_FAILURE; - } - - return giovfs->ShowURIForInput(dirPath); } + if (NS_SUCCEEDED(giovfs->OrgFreedesktopFileManager1ShowItems(mPath))) { + return NS_OK; + } + nsCOMPtr parentDir; + nsAutoCString dirPath; + if (NS_FAILED(GetParent(getter_AddRefs(parentDir)))) { + return NS_ERROR_FAILURE; + } + if (NS_FAILED(parentDir->GetNativePath(dirPath))) { + return NS_ERROR_FAILURE; + } + + return giovfs->ShowURIForInput(dirPath); #elif defined(MOZ_WIDGET_COCOA) CFURLRef url; if (NS_SUCCEEDED(GetCFURL(&url))) { diff --git a/xpcom/reflect/xptcall/md/unix/xptcstubs_x86_64_linux.cpp b/xpcom/reflect/xptcall/md/unix/xptcstubs_x86_64_linux.cpp index 01044363bf18..6fd980fe1a68 100644 --- a/xpcom/reflect/xptcall/md/unix/xptcstubs_x86_64_linux.cpp +++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_x86_64_linux.cpp @@ -69,30 +69,28 @@ PrepareAndDispatch(nsXPTCStubBase * self, uint32_t methodIndex, const nsXPTParamInfo& param = info->GetParam(i); const nsXPTType& type = param.GetType(); nsXPTCMiniVariant* dp = &dispatchParams[i]; - + if (!param.IsOut() && type == nsXPTType::T_DOUBLE) { if (nr_fpr < FPR_COUNT) dp->val.d = fpregs[nr_fpr++]; else - dp->val.d = *(double*) ap++; + dp->val.d = *(double*)ap++; continue; } - else if (!param.IsOut() && type == nsXPTType::T_FLOAT) { + if (!param.IsOut() && type == nsXPTType::T_FLOAT) { if (nr_fpr < FPR_COUNT) // The value in %xmm register is already prepared to // be retrieved as a float. Therefore, we pass the // value verbatim, as a double without conversion. dp->val.d = fpregs[nr_fpr++]; else - dp->val.f = *(float*) ap++; + dp->val.f = *(float*)ap++; continue; } - else { - if (nr_gpr < GPR_COUNT) - value = gpregs[nr_gpr++]; - else - value = *ap++; - } + if (nr_gpr < GPR_COUNT) + value = gpregs[nr_gpr++]; + else + value = *ap++; if (param.IsOut() || !type.IsArithmetic()) { dp->val.p = (void*) value;