From db444d2063df6c574882d9263e885c4fe1134133 Mon Sep 17 00:00:00 2001 From: weili Date: Thu, 2 Jun 2016 15:48:15 -0700 Subject: Fix all the code which has duplicate variable declarations When there are duplicate variable declarations, the inner names shadow the outter ones. This is error prone and harder to read. Remove all the instances found by /analyze. BUG=chromium:613623, chromium:427616 Review-Url: https://codereview.chromium.org/2027273002 --- xfa/fde/cfde_txtedtengine.cpp | 8 ++++---- xfa/fde/cfx_wordbreak.cpp | 12 ++++-------- xfa/fde/tto/fde_textout.cpp | 20 ++++++++------------ 3 files changed, 16 insertions(+), 24 deletions(-) (limited to 'xfa/fde') diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index ecdaf67120..4bdf8df1c0 100644 --- a/xfa/fde/cfde_txtedtengine.cpp +++ b/xfa/fde/cfde_txtedtengine.cpp @@ -899,10 +899,10 @@ void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) { int32_t nTotalCharCount = 0; int32_t i = 0; for (i = ParagPosBgn.nParagIndex; i <= ParagPosEnd.nParagIndex; i++) { - CFDE_TxtEdtParag* pParag = m_ParagPtrArray[i]; - pParag->CalcLines(); - nTotalLineCount += pParag->GetLineCount(); - nTotalCharCount += pParag->GetTextLength(); + CFDE_TxtEdtParag* pTextParag = m_ParagPtrArray[i]; + pTextParag->CalcLines(); + nTotalLineCount += pTextParag->GetLineCount(); + nTotalCharCount += pTextParag->GetTextLength(); } m_pTxtBuf->Delete(nStart, nCount); int32_t nNextParagIndex = (ParagPosBgn.nCharIndex == 0 && bLastParag) diff --git a/xfa/fde/cfx_wordbreak.cpp b/xfa/fde/cfx_wordbreak.cpp index 5b220df60e..a9aa75b622 100644 --- a/xfa/fde/cfx_wordbreak.cpp +++ b/xfa/fde/cfx_wordbreak.cpp @@ -2859,17 +2859,14 @@ FX_BOOL CFX_WordBreak::FindNextBreakPos(IFX_CharIter* pIter, } if (!(bFromNext || pIter->IsEOF(bPrev))) { pIter->Next(!bPrev); - FX_WCHAR wcTemp = pIter->GetChar(); - ePreType = GetWordBreakProperty(wcTemp); + ePreType = GetWordBreakProperty(pIter->GetChar()); pIter->Next(bPrev); } - FX_WCHAR wcTemp = pIter->GetChar(); - eCurType = GetWordBreakProperty(wcTemp); + eCurType = GetWordBreakProperty(pIter->GetChar()); FX_BOOL bFirst = TRUE; do { pIter->Next(bPrev); - FX_WCHAR wcTemp = pIter->GetChar(); - eNextType = GetWordBreakProperty(wcTemp); + eNextType = GetWordBreakProperty(pIter->GetChar()); uint16_t wBreak = gs_FX_WordBreak_Table[eCurType] & ((uint16_t)(1 << eNextType)); if (wBreak) { @@ -2929,8 +2926,7 @@ FX_BOOL CFX_WordBreak::FindNextBreakPos(IFX_CharIter* pIter, } ASSERT(nFlags <= 2); pIter->Next(bPrev); - wcTemp = pIter->GetChar(); - eNextType = (FX_WordBreakProp)GetWordBreakProperty(wcTemp); + eNextType = (FX_WordBreakProp)GetWordBreakProperty(pIter->GetChar()); if (!((nFlags == 1 && eNextType == FX_WordBreakProp_ALetter) || (nFlags == 2 && eNextType == FX_WordBreakProp_Numberic))) { pIter->Next(!bPrev); diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index c7d82ac0f4..1cf9226409 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -735,16 +735,14 @@ void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) { FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout); FX_FLOAT fLineStopS = bVertical ? rect.right() : rect.bottom(); int32_t iLines = m_ttoLines.GetSize(); - if (iLines < 1) { + if (iLines < 1) return; - } - CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(iLines - 1); - FDE_TTOPIECE* pPiece = pLine->GetPtrAt(0); - if (pPiece == NULL) { + FDE_TTOPIECE* pFirstPiece = m_ttoLines.GetPtrAt(iLines - 1)->GetPtrAt(0); + if (!pFirstPiece) return; - } + FX_FLOAT fLineStopD = - bVertical ? pPiece->rtPiece.right() : pPiece->rtPiece.bottom(); + bVertical ? pFirstPiece->rtPiece.right() : pFirstPiece->rtPiece.bottom(); FX_FLOAT fInc = fLineStopS - fLineStopD; if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft && m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) { @@ -752,19 +750,17 @@ void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) { } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) { fInc = 0.0f; } - if (fInc < 1.0f) { + if (fInc < 1.0f) return; - } for (int32_t i = 0; i < iLines; i++) { CFDE_TTOLine* pLine = m_ttoLines.GetPtrAt(i); int32_t iPieces = pLine->GetSize(); for (int32_t j = 0; j < iPieces; j++) { FDE_TTOPIECE* pPiece = pLine->GetPtrAt(j); - if (bVertical) { + if (bVertical) pPiece->rtPiece.left += fInc; - } else { + else pPiece->rtPiece.top += fInc; - } } } } -- cgit v1.2.3