From f49747f5fc85ea2acf0c5ff0ab589ad791bf6648 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 10 Jun 2016 15:24:47 -0700 Subject: Trust the compiler to do array indexing and superclass promotion. Review-Url: https://codereview.chromium.org/2063463002 --- xfa/fgas/layout/fgas_rtfbreak.cpp | 14 +++++--------- xfa/fgas/layout/fgas_textbreak.cpp | 6 ++---- xfa/fxbarcode/qrcode/BC_QRDetector.cpp | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index 388a3be6f9..eed37df35d 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -990,27 +990,23 @@ int32_t CFX_RTFBreak::GetBreakPos(CFX_RTFCharArray& tca, if (nNext == FX_CBP_SP) { eType = bSpaceBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (nCur << 5) + nNext); + eType = gs_FX_LineBreak_PairTable[nCur][nNext]; } } else if (nCur == FX_CBP_TB) { bNeedBreak = !bTabBreak; if (nNext == FX_CBP_TB) { eType = bTabBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (nCur << 5) + nNext); + eType = gs_FX_LineBreak_PairTable[nCur][nNext]; } - } else if (bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) { - eType = FX_LBT_DIRECT_BRK; - } else if (bInfixBreak && nCur == FX_CBP_IS && nNext == FX_CBP_IS) { + } else if ((bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) || + (bInfixBreak && nCur == FX_CBP_IS && nNext == FX_CBP_IS)) { eType = FX_LBT_DIRECT_BRK; } else { if (nNext == FX_CBP_SP) { eType = FX_LBT_PROHIBITED_BRK; } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (nCur << 5) + nNext); + eType = gs_FX_LineBreak_PairTable[nCur][nNext]; } } if (bAllChars) { diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index 56850c741c..c8d33baa80 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -1014,8 +1014,7 @@ int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca, if (nNext == FX_CBP_SP) { eType = bSpaceBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (nCur << 5) + nNext); + eType = gs_FX_LineBreak_PairTable[nCur][nNext]; } } else if (bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) { eType = FX_LBT_DIRECT_BRK; @@ -1023,8 +1022,7 @@ int32_t CFX_TxtBreak::GetBreakPos(CFX_TxtCharArray& ca, if (nNext == FX_CBP_SP) { eType = FX_LBT_PROHIBITED_BRK; } else { - eType = *((const FX_LINEBREAKTYPE*)gs_FX_LineBreak_PairTable + - (nCur << 5) + nNext); + eType = gs_FX_LineBreak_PairTable[nCur][nNext]; } } if (bAllChars) { diff --git a/xfa/fxbarcode/qrcode/BC_QRDetector.cpp b/xfa/fxbarcode/qrcode/BC_QRDetector.cpp index 3ed1ea14b8..a5be32a232 100644 --- a/xfa/fxbarcode/qrcode/BC_QRDetector.cpp +++ b/xfa/fxbarcode/qrcode/BC_QRDetector.cpp @@ -91,7 +91,7 @@ CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo( } CBC_CommonBitMatrix* bits = SampleGrid(m_image, topLeft.get(), topRight.get(), bottomLeft.get(), - (CBC_ResultPoint*)(alignmentPattern), dimension, e); + alignmentPattern, dimension, e); BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); CFX_ArrayTemplate* points = -- cgit v1.2.3