diff options
author | Lei Zhang <thestig@chromium.org> | 2018-09-25 21:37:23 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-09-25 21:37:23 +0000 |
commit | 072d829e2cd1586645022498a01a61db83a2db4d (patch) | |
tree | 97c6f9667257f48dfd84965629ae4022bcba8322 /fxbarcode/qrcode | |
parent | 9412c8ec36d1bd1b8a5fbc827b3b6f513c2a56a3 (diff) | |
download | pdfium-072d829e2cd1586645022498a01a61db83a2db4d.tar.xz |
Optimize MaybeEmbedPositionAdjustmentPatterns().chromium/3563chromium/3562
Change-Id: I547288c19c714a8222af89e0499d6786dad917c7
Reviewed-on: https://pdfium-review.googlesource.com/42457
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxbarcode/qrcode')
-rw-r--r-- | fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp index 5320303630..2a13ade90c 100644 --- a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp +++ b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp @@ -41,29 +41,28 @@ constexpr uint8_t POSITION_ADJUSTMENT_PATTERN[5][5] = {{1, 1, 1, 1, 1}, {1, 0, 0, 0, 1}, {1, 1, 1, 1, 1}}; -constexpr int16_t POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[39][7] = - // NOLINTNEXTLINE - { - {6, 18, -1, -1, -1, -1, -1}, {6, 22, -1, -1, -1, -1, -1}, - {6, 26, -1, -1, -1, -1, -1}, {6, 30, -1, -1, -1, -1, -1}, - {6, 34, -1, -1, -1, -1, -1}, {6, 22, 38, -1, -1, -1, -1}, - {6, 24, 42, -1, -1, -1, -1}, {6, 26, 46, -1, -1, -1, -1}, - {6, 28, 50, -1, -1, -1, -1}, {6, 30, 54, -1, -1, -1, -1}, - {6, 32, 58, -1, -1, -1, -1}, {6, 34, 62, -1, -1, -1, -1}, - {6, 26, 46, 66, -1, -1, -1}, {6, 26, 48, 70, -1, -1, -1}, - {6, 26, 50, 74, -1, -1, -1}, {6, 30, 54, 78, -1, -1, -1}, - {6, 30, 56, 82, -1, -1, -1}, {6, 30, 58, 86, -1, -1, -1}, - {6, 34, 62, 90, -1, -1, -1}, {6, 28, 50, 72, 94, -1, -1}, - {6, 26, 50, 74, 98, -1, -1}, {6, 30, 54, 78, 102, -1, -1}, - {6, 28, 54, 80, 106, -1, -1}, {6, 32, 58, 84, 110, -1, -1}, - {6, 30, 58, 86, 114, -1, -1}, {6, 34, 62, 90, 118, -1, -1}, - {6, 26, 50, 74, 98, 122, -1}, {6, 30, 54, 78, 102, 126, -1}, - {6, 26, 52, 78, 104, 130, -1}, {6, 30, 56, 82, 108, 134, -1}, - {6, 34, 60, 86, 112, 138, -1}, {6, 30, 58, 86, 114, 142, -1}, - {6, 34, 62, 90, 118, 146, -1}, {6, 30, 54, 78, 102, 126, 150}, - {6, 24, 50, 76, 102, 128, 154}, {6, 28, 54, 80, 106, 132, 158}, - {6, 32, 58, 84, 110, 136, 162}, {6, 26, 54, 82, 110, 138, 166}, - {6, 30, 58, 86, 114, 142, 170}, +constexpr size_t kNumCoordinate = 7; +constexpr uint8_t kPositionAdjustmentPatternCoordinates[39][kNumCoordinate] = { + {6, 18, 0, 0, 0, 0, 0}, {6, 22, 0, 0, 0, 0, 0}, + {6, 26, 0, 0, 0, 0, 0}, {6, 30, 0, 0, 0, 0, 0}, + {6, 34, 0, 0, 0, 0, 0}, {6, 22, 38, 0, 0, 0, 0}, + {6, 24, 42, 0, 0, 0, 0}, {6, 26, 46, 0, 0, 0, 0}, + {6, 28, 50, 0, 0, 0, 0}, {6, 30, 54, 0, 0, 0, 0}, + {6, 32, 58, 0, 0, 0, 0}, {6, 34, 62, 0, 0, 0, 0}, + {6, 26, 46, 66, 0, 0, 0}, {6, 26, 48, 70, 0, 0, 0}, + {6, 26, 50, 74, 0, 0, 0}, {6, 30, 54, 78, 0, 0, 0}, + {6, 30, 56, 82, 0, 0, 0}, {6, 30, 58, 86, 0, 0, 0}, + {6, 34, 62, 90, 0, 0, 0}, {6, 28, 50, 72, 94, 0, 0}, + {6, 26, 50, 74, 98, 0, 0}, {6, 30, 54, 78, 102, 0, 0}, + {6, 28, 54, 80, 106, 0, 0}, {6, 32, 58, 84, 110, 0, 0}, + {6, 30, 58, 86, 114, 0, 0}, {6, 34, 62, 90, 118, 0, 0}, + {6, 26, 50, 74, 98, 122, 0}, {6, 30, 54, 78, 102, 126, 0}, + {6, 26, 52, 78, 104, 130, 0}, {6, 30, 56, 82, 108, 134, 0}, + {6, 34, 60, 86, 112, 138, 0}, {6, 30, 58, 86, 114, 142, 0}, + {6, 34, 62, 90, 118, 146, 0}, {6, 30, 54, 78, 102, 126, 150}, + {6, 24, 50, 76, 102, 128, 154}, {6, 28, 54, 80, 106, 132, 158}, + {6, 32, 58, 84, 110, 136, 162}, {6, 26, 54, 82, 110, 138, 166}, + {6, 30, 58, 86, 114, 142, 170}, }; const uint8_t TYPE_INFO_COORDINATES[15][2] = { @@ -346,18 +345,18 @@ bool MaybeEmbedPositionAdjustmentPatterns(int32_t version, return true; const size_t index = version - 2; - if (index >= FX_ArraySize(POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE)) + if (index >= FX_ArraySize(kPositionAdjustmentPatternCoordinates)) return false; - const auto* coordinates = - &POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index][0]; - constexpr int32_t numCoordinate = 7; - for (int32_t i = 0; i < numCoordinate; i++) { - for (int32_t j = 0; j < numCoordinate; j++) { - int32_t y = coordinates[i]; - int32_t x = coordinates[j]; - if (x == -1 || y == -1) - continue; + const auto* coordinates = &kPositionAdjustmentPatternCoordinates[index][0]; + for (size_t i = 0; i < kNumCoordinate; i++) { + const int32_t y = coordinates[i]; + if (y == 0) + break; + for (size_t j = 0; j < kNumCoordinate; j++) { + const int32_t x = coordinates[j]; + if (x == 0) + break; if (IsEmpty(matrix->Get(x, y))) { if (!EmbedPositionAdjustmentPattern(x - 2, y - 2, matrix)) |