From 588a35b1db1e03721af62a02ec910c7583b7118a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 21 May 2018 18:36:08 +0000 Subject: Avoid indexing into std::vector inside a tight loop. In CCodec_FaxDecoder::v_GetNextLine(), a fixed size vector often needs to be inverted. Doing so without checking bounds on every access makes a big difference in non-optimized builds. BUG=chromium:843899 Change-Id: Iecc0a3da22631a289745245563dab7a7c3c458d0 Reviewed-on: https://pdfium-review.googlesource.com/32744 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- core/fxcodec/codec/fx_codec_fax.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core/fxcodec/codec') diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp index 4a70b5302e..0a6ba3a793 100644 --- a/core/fxcodec/codec/fx_codec_fax.cpp +++ b/core/fxcodec/codec/fx_codec_fax.cpp @@ -544,8 +544,10 @@ uint8_t* CCodec_FaxDecoder::v_GetNextLine() { m_bitpos = bitpos1; } if (m_bBlack) { - for (uint32_t i = 0; i < m_Pitch; ++i) - m_ScanlineBuf[i] = ~m_ScanlineBuf[i]; + ASSERT(m_Pitch == m_ScanlineBuf.size()); + uint8_t* data = m_ScanlineBuf.data(); + for (size_t i = 0; i < m_ScanlineBuf.size(); ++i) + data[i] = ~data[i]; } return m_ScanlineBuf.data(); } -- cgit v1.2.3