diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-03-14 15:53:36 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-15 00:03:38 +0000 |
commit | 193e6ca5e48ee99e620f0e7546f1407ba1a20323 (patch) | |
tree | 11d920c59a89247d28fe590d77ab6d6a9ce37a0c /xfa/fde/xml | |
parent | cd5139a291113f177d3494990efbcaf388d1f3bf (diff) | |
download | pdfium-193e6ca5e48ee99e620f0e7546f1407ba1a20323.tar.xz |
Add IndexInBounds() convenience routine.
Avoid writing |Type| in CollectionSize<Type>() so that index
type can change without rewriting conditions.
Change-Id: I40c94ca39148b379908760ba9b861114b88af7bb
Reviewed-on: https://pdfium-review.googlesource.com/3056
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fde/xml')
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp index 0959661b26..334410049c 100644 --- a/xfa/fde/xml/fde_xml_imp.cpp +++ b/xfa/fde/xml/fde_xml_imp.cpp @@ -652,7 +652,7 @@ int32_t CFDE_XMLInstruction::CountData() const { } bool CFDE_XMLInstruction::GetData(int32_t index, CFX_WideString& wsData) const { - if (index < 0 || index >= pdfium::CollectionSize<int32_t>(m_TargetData)) + if (!pdfium::IndexInBounds(m_TargetData, index)) return false; wsData = m_TargetData[index]; @@ -664,10 +664,8 @@ void CFDE_XMLInstruction::AppendData(const CFX_WideString& wsData) { } void CFDE_XMLInstruction::RemoveData(int32_t index) { - if (index < 0 || index >= pdfium::CollectionSize<int32_t>(m_TargetData)) - return; - - m_TargetData.erase(m_TargetData.begin() + index); + if (pdfium::IndexInBounds(m_TargetData, index)) + m_TargetData.erase(m_TargetData.begin() + index); } CFDE_XMLInstruction::~CFDE_XMLInstruction() {} |