summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-03-19 18:08:36 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-03-19 18:08:36 +0000
commitb020a8ca7def8d7f8298bb754870e7e808a070e3 (patch)
tree1e7b60ac1a9428c841bf394dbfcd54d7a4f74430 /core
parent704a617ec011cda5c821d210c83f311f0ba5b15c (diff)
downloadpdfium-b020a8ca7def8d7f8298bb754870e7e808a070e3.tar.xz
Remove redundant code in CPDF_TextPage::CountRects().
CountRects() calls GetRectArray(), which performs the same calculation. Change-Id: I79dcd8e82f6d0fe7ed992da06237f31d0761a902 Reviewed-on: https://pdfium-review.googlesource.com/28734 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdftext/cpdf_textpage.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 91cfe8c6c9..81c528f4c5 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -173,7 +173,7 @@ void CPDF_TextPage::ParseTextPage() {
m_bIsParsed = true;
m_CharIndex.clear();
- int nCount = pdfium::CollectionSize<int>(m_CharList);
+ const int nCount = CountChars();
if (nCount)
m_CharIndex.push_back(0);
@@ -320,7 +320,8 @@ int CPDF_TextPage::GetIndexAtPos(const CFX_PointF& point,
int NearPos = -1;
double xdif = 5000;
double ydif = 5000;
- while (pos < pdfium::CollectionSize<int>(m_CharList)) {
+ const int nCount = CountChars();
+ while (pos < nCount) {
PAGECHAR_INFO charinfo = m_CharList[pos];
CFX_FloatRect charrect = charinfo.m_CharBox;
if (charrect.Contains(point))
@@ -349,7 +350,7 @@ int CPDF_TextPage::GetIndexAtPos(const CFX_PointF& point,
}
++pos;
}
- return pos < pdfium::CollectionSize<int>(m_CharList) ? pos : NearPos;
+ return pos < nCount ? pos : NearPos;
}
WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
@@ -467,10 +468,6 @@ int CPDF_TextPage::CountRects(int start, int nCount) {
if (!m_bIsParsed || start < 0)
return -1;
- if (nCount == -1 ||
- nCount + start > pdfium::CollectionSize<int>(m_CharList)) {
- nCount = pdfium::CollectionSize<int>(m_CharList) - start;
- }
m_SelRects = GetRectArray(start, nCount);
return pdfium::CollectionSize<int>(m_SelRects);
}