diff options
author | Lei Zhang <thestig@chromium.org> | 2018-05-16 18:21:56 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-16 18:21:56 +0000 |
commit | c8f4e72cc26bd749bba8ad0d44d2c2bf838714b0 (patch) | |
tree | 4df470c7d303b965757f48d9b851e3c6bb38e244 | |
parent | 2be77a455df631ecbb5fbcc3f763bc606d7236f3 (diff) | |
download | pdfium-c8f4e72cc26bd749bba8ad0d44d2c2bf838714b0.tar.xz |
Avoid a memset() in FindBit() in the fax codec.
FindBit() is called frequently by other fax codec code. Use 16 more
bytes of space to store the two possible values memset() can set.
Change-Id: Ibeb549c44928bbb468ac4eb4cef2d9339cf6490d
Reviewed-on: https://pdfium-review.googlesource.com/32630
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r-- | core/fxcodec/codec/fx_codec_fax.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp index 8c4b215a1b..09d0ebc157 100644 --- a/core/fxcodec/codec/fx_codec_fax.cpp +++ b/core/fxcodec/codec/fx_codec_fax.cpp @@ -73,8 +73,11 @@ int FindBit(const uint8_t* data_buf, int max_pos, int start_pos, bool bit) { // Try reading in bigger chunks in case there are long runs to be skipped. static constexpr int kBulkReadSize = 8; if (max_byte >= kBulkReadSize && byte_pos < max_byte - kBulkReadSize) { - uint8_t skip_block[kBulkReadSize]; - memset(skip_block, skip, kBulkReadSize); + static constexpr uint8_t skip_block_0[kBulkReadSize] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + static constexpr uint8_t skip_block_1[kBulkReadSize] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + const uint8_t* skip_block = bit ? skip_block_0 : skip_block_1; while (byte_pos < max_byte - kBulkReadSize && memcmp(data_buf + byte_pos, skip_block, kBulkReadSize) == 0) { byte_pos += kBulkReadSize; |