From b8d86800487df4021860f08407c323ed82243c79 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 1 Dec 2017 22:52:42 +0000 Subject: Get rid of else after break/continue/return. Change-Id: I3efc57cd7325d16e3ca8ebdeeaec06012b2c56e3 Reviewed-on: https://pdfium-review.googlesource.com/20110 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- xfa/fgas/crt/cfgas_formatstring.cpp | 39 ++++++++--------- xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp | 3 +- xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 4 +- xfa/fxfa/parser/cxfa_nodehelper.cpp | 62 ++++++++++++---------------- 4 files changed, 50 insertions(+), 58 deletions(-) (limited to 'xfa') diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp index eaac969fd8..b8f6eeefca 100644 --- a/xfa/fgas/crt/cfgas_formatstring.cpp +++ b/xfa/fgas/crt/cfgas_formatstring.cpp @@ -246,7 +246,8 @@ bool ParseLocaleDate(const WideString& wsDate, *cc += iLiteralLen; ccf++; continue; - } else if (!wsDateSymbols.Contains(strf[ccf])) { + } + if (!wsDateSymbols.Contains(strf[ccf])) { if (strf[ccf] != str[*cc]) return false; (*cc)++; @@ -885,6 +886,16 @@ FX_LOCALECATEGORY CFGAS_FormatString::GetCategory(const WideString& wsPattern) { } uint32_t dwHash = FX_HashCode_GetW(wsCategory.AsStringView(), false); + if (dwHash == FX_LOCALECATEGORY_DateTimeHash) + return FX_LOCALECATEGORY_DateTime; + if (dwHash == FX_LOCALECATEGORY_TextHash) + return FX_LOCALECATEGORY_Text; + if (dwHash == FX_LOCALECATEGORY_NumHash) + return FX_LOCALECATEGORY_Num; + if (dwHash == FX_LOCALECATEGORY_ZeroHash) + return FX_LOCALECATEGORY_Zero; + if (dwHash == FX_LOCALECATEGORY_NullHash) + return FX_LOCALECATEGORY_Null; if (dwHash == FX_LOCALECATEGORY_DateHash) { if (eCategory == FX_LOCALECATEGORY_Time) return FX_LOCALECATEGORY_DateTime; @@ -893,16 +904,6 @@ FX_LOCALECATEGORY CFGAS_FormatString::GetCategory(const WideString& wsPattern) { if (eCategory == FX_LOCALECATEGORY_Date) return FX_LOCALECATEGORY_DateTime; eCategory = FX_LOCALECATEGORY_Time; - } else if (dwHash == FX_LOCALECATEGORY_DateTimeHash) { - return FX_LOCALECATEGORY_DateTime; - } else if (dwHash == FX_LOCALECATEGORY_TextHash) { - return FX_LOCALECATEGORY_Text; - } else if (dwHash == FX_LOCALECATEGORY_NumHash) { - return FX_LOCALECATEGORY_Num; - } else if (dwHash == FX_LOCALECATEGORY_ZeroHash) { - return FX_LOCALECATEGORY_Zero; - } else if (dwHash == FX_LOCALECATEGORY_NullHash) { - return FX_LOCALECATEGORY_Null; } } else if (pStr[ccf] == '}') { bBraceOpen = false; @@ -990,6 +991,10 @@ IFX_Locale* CFGAS_FormatString::GetNumericFormat(const WideString& wsPattern, continue; } while (ccf < iLenf) { + if (pStr[ccf] == '{') { + bBrackOpen = true; + break; + } if (pStr[ccf] == '(') { ccf++; WideString wsLCID; @@ -997,9 +1002,6 @@ IFX_Locale* CFGAS_FormatString::GetNumericFormat(const WideString& wsPattern, wsLCID += pStr[ccf++]; pLocale = m_pLocaleMgr->GetLocaleByName(wsLCID); - } else if (pStr[ccf] == '{') { - bBrackOpen = true; - break; } else if (pStr[ccf] == '.') { WideString wsSubCategory; ccf++; @@ -1593,6 +1595,10 @@ FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat( continue; } while (ccf < iLenf) { + if (pStr[ccf] == '{') { + bBraceOpen = true; + break; + } if (pStr[ccf] == '(') { ccf++; WideString wsLCID; @@ -1600,9 +1606,6 @@ FX_DATETIMETYPE CFGAS_FormatString::GetDateTimeFormat( wsLCID += pStr[ccf++]; *pLocale = m_pLocaleMgr->GetLocaleByName(wsLCID); - } else if (pStr[ccf] == '{') { - bBraceOpen = true; - break; } else if (pStr[ccf] == '.') { WideString wsSubCategory; ccf++; @@ -2314,10 +2317,8 @@ bool CFGAS_FormatString::FormatZero(const WideString& wsPattern, if (pStrPattern[iPattern] == '\'') { *wsOutput += GetLiteralText(pStrPattern, &iPattern, iLenPattern); iPattern++; - continue; } else { *wsOutput += pStrPattern[iPattern++]; - continue; } } return true; diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp index cb52c9de08..05485d1951 100644 --- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp @@ -2543,8 +2543,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer( true); if (bAddedItemInRow && eFlowStrategy == XFA_AttributeEnum::Tb) break; - else - continue; + continue; SuspendAndCreateNewRow: if (pProcessor) m_pCurChildPreprocessor = pProcessor.release(); diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 90e0b15de6..1e8a77307f 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -1261,8 +1261,8 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( eCurPagePosition == ePreferredPosition) { pPreferredPageArea = pCurrentNode; break; - } else if (eCurPagePosition == eFallbackPosition && - !pFallbackPageArea) { + } + if (eCurPagePosition == eFallbackPosition && !pFallbackPageArea) { pFallbackPageArea = pCurrentNode; } } else if (pTargetPageArea && !MatchPageAreaOddOrEven(pTargetPageArea)) { diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp index 6428a3ca4a..f11472a112 100644 --- a/xfa/fxfa/parser/cxfa_nodehelper.cpp +++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp @@ -267,16 +267,13 @@ void CXFA_NodeHelper::GetNameExpression(CXFA_Node* refNode, } bool CXFA_NodeHelper::NodeIsTransparent(CXFA_Node* refNode) { - if (!refNode) { + if (!refNode) return false; - } + XFA_Element refNodeType = refNode->GetElementType(); - if ((refNode->IsUnnamed() && refNode->IsContainerNode()) || - refNodeType == XFA_Element::SubformSet || - refNodeType == XFA_Element::Area || refNodeType == XFA_Element::Proto) { - return true; - } - return false; + return (refNode->IsUnnamed() && refNode->IsContainerNode()) || + refNodeType == XFA_Element::SubformSet || + refNodeType == XFA_Element::Area || refNodeType == XFA_Element::Proto; } bool CXFA_NodeHelper::CreateNode_ForCondition(WideString& wsCondition) { @@ -287,34 +284,29 @@ bool CXFA_NodeHelper::CreateNode_ForCondition(WideString& wsCondition) { m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; return false; } - if (wsCondition[0] == '[') { - int32_t i = 1; - for (; i < iLen; ++i) { - wchar_t ch = wsCondition[i]; - if (ch == ' ') { - continue; - } - if (ch == '+' || ch == '-') { - break; - } else if (ch == '*') { - bAll = true; - break; - } else { - break; - } - } - if (bAll) { - wsIndex = L"1"; - m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeAll; - } else { - m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; - wsIndex = wsCondition.Mid(i, iLen - 1 - i); - } - int32_t iIndex = wsIndex.GetInteger(); - m_iCreateCount = iIndex; - return true; + if (wsCondition[0] != '[') + return false; + + int32_t i = 1; + for (; i < iLen; ++i) { + wchar_t ch = wsCondition[i]; + if (ch == ' ') + continue; + + if (ch == '*') + bAll = true; + break; + } + if (bAll) { + wsIndex = L"1"; + m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeAll; + } else { + m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne; + wsIndex = wsCondition.Mid(i, iLen - 1 - i); } - return false; + int32_t iIndex = wsIndex.GetInteger(); + m_iCreateCount = iIndex; + return true; } bool CXFA_NodeHelper::ResolveNodes_CreateNode(WideString wsName, -- cgit v1.2.3