From 193e6ca5e48ee99e620f0e7546f1407ba1a20323 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 14 Mar 2017 15:53:36 -0700 Subject: Add IndexInBounds() convenience routine. Avoid writing |Type| in CollectionSize() so that index type can change without rewriting conditions. Change-Id: I40c94ca39148b379908760ba9b861114b88af7bb Reviewed-on: https://pdfium-review.googlesource.com/3056 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- xfa/fgas/layout/fgas_textbreak.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'xfa/fgas/layout/fgas_textbreak.cpp') diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index 8bba780382..c42de45411 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -796,11 +796,10 @@ int32_t CFX_TxtBreak::CountBreakPieces() const { const CFX_BreakPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { if (!HasTxtLine()) return nullptr; - if (index < 0 || - index >= pdfium::CollectionSize( - m_TxtLine[m_iReadyLineIndex].m_LinePieces)) { + + if (!pdfium::IndexInBounds(m_TxtLine[m_iReadyLineIndex].m_LinePieces, index)) return nullptr; - } + return &m_TxtLine[m_iReadyLineIndex].m_LinePieces[index]; } -- cgit v1.2.3