From 821c7236cea91645d32e1028b6f40d500961441c Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 26 Feb 2018 22:20:02 +0000 Subject: Shrink some tables and kill dead code in xfa. Change-Id: Ic1260417e7d1475dd518655b2ab08f0184955d88 Reviewed-on: https://pdfium-review.googlesource.com/27170 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- core/fxcodec/jbig2/JBig2_ArithDecoder.cpp | 8 +++--- fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp | 46 ++++++++++++++++--------------- fxbarcode/qrcode/BC_QRCoderMatrixUtil.h | 11 -------- xfa/fxfa/fxfa_basic.h | 4 +-- xfa/fxfa/parser/cxfa_localevalue.cpp | 4 +-- 5 files changed, 32 insertions(+), 41 deletions(-) diff --git a/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp b/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp index deba72bfc5..ba42644e94 100644 --- a/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp +++ b/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp @@ -12,10 +12,10 @@ namespace { struct JBig2ArithQe { - unsigned int Qe; - unsigned int NMPS; - unsigned int NLPS; - unsigned int nSwitch; + uint16_t Qe; + uint8_t NMPS; + uint8_t NLPS; + uint8_t nSwitch; }; const JBig2ArithQe kQeTable[] = { diff --git a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp index d5b7bcd69d..64b8685177 100644 --- a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp +++ b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp @@ -28,23 +28,21 @@ #include "fxbarcode/qrcode/BC_QRCoderMatrixUtil.h" #include "fxbarcode/utils.h" -const int32_t CBC_QRCoderMatrixUtil::POSITION_DETECTION_PATTERN[7][7] = { +namespace { + +const uint8_t POSITION_DETECTION_PATTERN[7][7] = { {1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 1}, {1, 0, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 0, 1}, {1, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1}}; -const int32_t CBC_QRCoderMatrixUtil::HORIZONTAL_SEPARATION_PATTERN[1][8] = { - {0, 0, 0, 0, 0, 0, 0, 0}}; -const int32_t CBC_QRCoderMatrixUtil::VERTICAL_SEPARATION_PATTERN[7][1] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}}; -const int32_t CBC_QRCoderMatrixUtil::POSITION_ADJUSTMENT_PATTERN[5][5] = { - {1, 1, 1, 1, 1}, - {1, 0, 0, 0, 1}, - {1, 0, 1, 0, 1}, - {1, 0, 0, 0, 1}, - {1, 1, 1, 1, 1}}; -const int32_t - CBC_QRCoderMatrixUtil::POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[40][7] = - // NOLINTNEXTLINE + +const uint8_t POSITION_ADJUSTMENT_PATTERN[5][5] = {{1, 1, 1, 1, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 1, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 1}}; + +const int16_t POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[40][7] = + // NOLINTNEXTLINE { {-1, -1, -1, -1, -1, -1, -1}, {6, 18, -1, -1, -1, -1, -1}, {6, 22, -1, -1, -1, -1, -1}, {6, 26, -1, -1, -1, -1, -1}, @@ -67,13 +65,17 @@ const int32_t {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 int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_COORDINATES[15][2] = { + +const uint8_t TYPE_INFO_COORDINATES[15][2] = { {8, 0}, {8, 1}, {8, 2}, {8, 3}, {8, 4}, {8, 5}, {8, 7}, {8, 8}, {7, 8}, {5, 8}, {4, 8}, {3, 8}, {2, 8}, {1, 8}, {0, 8}, }; -const int32_t CBC_QRCoderMatrixUtil::VERSION_INFO_POLY = 0x1f25; -const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_POLY = 0x0537; -const int32_t CBC_QRCoderMatrixUtil::TYPE_INFO_MASK_PATTERN = 0x5412; + +const int32_t VERSION_INFO_POLY = 0x1f25; +const int32_t TYPE_INFO_POLY = 0x0537; +const int32_t TYPE_INFO_MASK_PATTERN = 0x5412; + +} // namespace void CBC_QRCoderMatrixUtil::ClearMatrix(CBC_CommonByteMatrix* matrix, int32_t& e) { @@ -352,7 +354,7 @@ void CBC_QRCoderMatrixUtil::EmbedHorizontalSeparationPattern( e = BCExceptionInvalidateData; return; } - matrix->Set(xStart + x, yStart, HORIZONTAL_SEPARATION_PATTERN[0][x]); + matrix->Set(xStart + x, yStart, 0); } } void CBC_QRCoderMatrixUtil::EmbedVerticalSeparationPattern( @@ -369,7 +371,7 @@ void CBC_QRCoderMatrixUtil::EmbedVerticalSeparationPattern( e = BCExceptionInvalidateData; return; } - matrix->Set(xStart, yStart + y, VERTICAL_SEPARATION_PATTERN[y][0]); + matrix->Set(xStart, yStart + y, 0); } } void CBC_QRCoderMatrixUtil::EmbedPositionAdjustmentPattern( @@ -464,8 +466,8 @@ void CBC_QRCoderMatrixUtil::MaybeEmbedPositionAdjustmentPatterns( return; } int32_t index = version - 1; - int32_t const* coordinates = - &(POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index][0]); + const auto* coordinates = + &POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index][0]; int32_t numCoordinate = 7; for (int32_t i = 0; i < numCoordinate; i++) { for (int32_t j = 0; j < numCoordinate; j++) { diff --git a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h index 23fe0df8da..c6af3f25f2 100644 --- a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h +++ b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h @@ -72,17 +72,6 @@ class CBC_QRCoderMatrixUtil { static void MaybeEmbedPositionAdjustmentPatterns(int32_t version, CBC_CommonByteMatrix* matrix, int32_t& e); - - private: - static const int32_t POSITION_DETECTION_PATTERN[7][7]; - static const int32_t VERTICAL_SEPARATION_PATTERN[7][1]; - static const int32_t HORIZONTAL_SEPARATION_PATTERN[1][8]; - static const int32_t POSITION_ADJUSTMENT_PATTERN[5][5]; - static const int32_t POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[40][7]; - static const int32_t TYPE_INFO_COORDINATES[15][2]; - static const int32_t VERSION_INFO_POLY; - static const int32_t TYPE_INFO_POLY; - static const int32_t TYPE_INFO_MASK_PATTERN; }; #endif // FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_ diff --git a/xfa/fxfa/fxfa_basic.h b/xfa/fxfa/fxfa_basic.h index 96b483d978..d040bb3873 100644 --- a/xfa/fxfa/fxfa_basic.h +++ b/xfa/fxfa/fxfa_basic.h @@ -95,7 +95,7 @@ enum XFA_XDPPACKET_FLAGS { XFA_XDPPACKET_FLAGS_SUPPORTMANY = 16, }; -enum class XFA_AttributeEnum : uint32_t { +enum class XFA_AttributeEnum : uint16_t { Asterisk, Slash, Backslash, @@ -611,7 +611,7 @@ enum class XFA_Attribute : uint8_t { Unknown = 255, }; -enum class XFA_Element : int32_t { +enum class XFA_Element : int16_t { Unknown = -1, Ps, diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp index 09e3577887..756d4c2307 100644 --- a/xfa/fxfa/parser/cxfa_localevalue.cpp +++ b/xfa/fxfa/parser/cxfa_localevalue.cpp @@ -430,8 +430,8 @@ bool CXFA_LocaleValue::ValidateCanonicalValue(const WideString& wsValue, bool CXFA_LocaleValue::ValidateCanonicalDate(const WideString& wsDate, CFX_DateTime* unDate) { - static const uint16_t LastDay[12] = {31, 28, 31, 30, 31, 30, - 31, 31, 30, 31, 30, 31}; + static const uint8_t LastDay[12] = {31, 28, 31, 30, 31, 30, + 31, 31, 30, 31, 30, 31}; static const uint16_t wCountY = 4; static const uint16_t wCountM = 2; static const uint16_t wCountD = 2; -- cgit v1.2.3