diff options
author | Lei Zhang <thestig@chromium.org> | 2018-05-21 18:36:08 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-21 18:36:08 +0000 |
commit | 588a35b1db1e03721af62a02ec910c7583b7118a (patch) | |
tree | 6e828f88fb88d15e61e756cdfa4872109cee0db4 | |
parent | 9e17392183861a2b8b64abb4d528c79613ad3d57 (diff) | |
download | pdfium-chromium/3437.tar.xz |
Avoid indexing into std::vector inside a tight loop.chromium/3437
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 <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r-- | core/fxcodec/codec/fx_codec_fax.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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(); } |