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 --- core/fpdftext/cpdf_textpage.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'core/fpdftext/cpdf_textpage.cpp') diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 7a89b24171..1eab19f4f1 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -378,10 +378,7 @@ CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const { } void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const { - if (!m_bIsParsed) - return; - - if (index < 0 || index >= pdfium::CollectionSize(m_CharList)) + if (!m_bIsParsed || !pdfium::IndexInBounds(m_CharList, index)) return; const PAGECHAR_INFO& charinfo = m_CharList[index]; @@ -496,10 +493,7 @@ void CPDF_TextPage::GetRect(int rectIndex, float& top, float& right, float& bottom) const { - if (!m_bIsParsed) - return; - - if (rectIndex < 0 || rectIndex >= pdfium::CollectionSize(m_SelRects)) + if (!m_bIsParsed || !pdfium::IndexInBounds(m_SelRects, rectIndex)) return; left = m_SelRects[rectIndex].left; -- cgit v1.2.3