Remove some fxcrt::CollectionSize() usage in CPVT_VariableText.
Bug: pdfium:774
Change-Id: I655176910293121056a3fc2073fb6920eac161f7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/96061
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpvt_variabletext.cpp b/core/fpdfdoc/cpvt_variabletext.cpp
index b404838..19da19f 100644
--- a/core/fpdfdoc/cpvt_variabletext.cpp
+++ b/core/fpdfdoc/cpvt_variabletext.cpp
@@ -305,7 +305,7 @@
void CPVT_VariableText::UpdateWordPlace(CPVT_WordPlace& place) const {
if (place.nSecIndex < 0)
place = GetBeginWordPlace();
- if (place.nSecIndex >= fxcrt::CollectionSize<int32_t>(m_SectionArray))
+ if (static_cast<size_t>(place.nSecIndex) >= m_SectionArray.size())
place = GetEndWordPlace();
place = PrevLineHeaderPlace(place);
@@ -337,8 +337,7 @@
int32_t nOldIndex = 0;
int32_t nIndex = 0;
bool bFound = false;
- for (int32_t i = 0, sz = fxcrt::CollectionSize<int32_t>(m_SectionArray);
- i < sz; i++) {
+ for (size_t i = 0; i < m_SectionArray.size(); ++i) {
CPVT_Section* pSection = m_SectionArray[i].get();
nIndex += pSection->GetWordArraySize();
if (nIndex == index) {
@@ -347,13 +346,13 @@
break;
}
if (nIndex > index) {
- place.nSecIndex = i;
+ place.nSecIndex = pdfium::base::checked_cast<int32_t>(i);
place.nWordIndex = index - nOldIndex - 1;
pSection->UpdateWordPlace(place);
bFound = true;
break;
}
- if (i != sz - 1)
+ if (i != m_SectionArray.size() - 1)
nIndex += kReturnLength;
nOldIndex = nIndex;
}
@@ -376,7 +375,7 @@
const CPVT_WordPlace& place) const {
if (place.nSecIndex < 0)
return GetBeginWordPlace();
- if (place.nSecIndex >= fxcrt::CollectionSize<int32_t>(m_SectionArray))
+ if (static_cast<size_t>(place.nSecIndex) >= m_SectionArray.size())
return GetEndWordPlace();
CPVT_Section* pSection = m_SectionArray[place.nSecIndex].get();
@@ -391,7 +390,7 @@
const CPVT_WordPlace& place) const {
if (place.nSecIndex < 0)
return GetBeginWordPlace();
- if (place.nSecIndex >= fxcrt::CollectionSize<int32_t>(m_SectionArray))
+ if (static_cast<size_t>(place.nSecIndex) >= m_SectionArray.size())
return GetEndWordPlace();
CPVT_Section* pSection = m_SectionArray[place.nSecIndex].get();