Small cleanup on CPVT_Wordplace -- Move initialization to member decls -- Use default ctor in one caller -- assert const member at construction time. Change-Id: I9d3c96dca607c82d9fcad170bac6e5c5869a55d0 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79310 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index 57df06f..ce48851 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -78,8 +78,9 @@ return 0; } -CPDF_VariableText::Iterator::Iterator(CPDF_VariableText* pVT) - : m_CurPos(-1, -1, -1), m_pVT(pVT) {} +CPDF_VariableText::Iterator::Iterator(CPDF_VariableText* pVT) : m_pVT(pVT) { + DCHECK(m_pVT); +} CPDF_VariableText::Iterator::~Iterator() = default; @@ -88,7 +89,6 @@ } void CPDF_VariableText::Iterator::SetAt(const CPVT_WordPlace& place) { - DCHECK(m_pVT); m_CurPos = place; }
diff --git a/core/fpdfdoc/cpvt_wordplace.h b/core/fpdfdoc/cpvt_wordplace.h index c0a1a9c..8843757 100644 --- a/core/fpdfdoc/cpvt_wordplace.h +++ b/core/fpdfdoc/cpvt_wordplace.h
@@ -10,7 +10,7 @@ #include "core/fxcrt/fx_system.h" struct CPVT_WordPlace { - CPVT_WordPlace() : nSecIndex(-1), nLineIndex(-1), nWordIndex(-1) {} + CPVT_WordPlace() = default; CPVT_WordPlace(int32_t other_nSecIndex, int32_t other_nLineIndex, @@ -65,9 +65,9 @@ return nLineIndex - wp.nLineIndex; } - int32_t nSecIndex; - int32_t nLineIndex; - int32_t nWordIndex; + int32_t nSecIndex = -1; + int32_t nLineIndex = -1; + int32_t nWordIndex = -1; }; #endif // CORE_FPDFDOC_CPVT_WORDPLACE_H_