Remove some useless calculations in fxbarcode.
num - 0 and num * 1 are not helpful. Remove some casts as well.
Change-Id: I816afd543501fb87ea0780cb0afb4754e7983324
Reviewed-on: https://pdfium-review.googlesource.com/c/45990
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxbarcode/cbc_ean13.cpp b/fxbarcode/cbc_ean13.cpp
index d2d69df..0c30b38 100644
--- a/fxbarcode/cbc_ean13.cpp
+++ b/fxbarcode/cbc_ean13.cpp
@@ -41,7 +41,7 @@
ByteString byteString = encodeContents.ToUTF8();
int32_t checksum = pWriter->CalcChecksum(byteString);
- byteString += checksum - 0 + '0';
+ byteString += checksum + '0';
encodeContents = WideString::FromUTF8(byteString.AsStringView());
}
if (length > 13)
diff --git a/fxbarcode/cbc_ean8.cpp b/fxbarcode/cbc_ean8.cpp
index b7f6a7b..ee3e14b 100644
--- a/fxbarcode/cbc_ean8.cpp
+++ b/fxbarcode/cbc_ean8.cpp
@@ -36,11 +36,11 @@
int32_t length = encodeContents.GetLength();
if (length <= 7) {
for (int32_t i = 0; i < 7 - length; i++)
- encodeContents = wchar_t('0') + encodeContents;
+ encodeContents = L'0' + encodeContents;
ByteString byteString = encodeContents.ToUTF8();
int32_t checksum = pWriter->CalcChecksum(byteString);
- encodeContents += wchar_t(checksum - 0 + '0');
+ encodeContents += L'0' + checksum;
}
if (length > 8)
encodeContents = encodeContents.Left(8);
diff --git a/fxbarcode/cbc_upca.cpp b/fxbarcode/cbc_upca.cpp
index c8f313a..369e6e2 100644
--- a/fxbarcode/cbc_upca.cpp
+++ b/fxbarcode/cbc_upca.cpp
@@ -36,11 +36,11 @@
int32_t length = encodeContents.GetLength();
if (length <= 11) {
for (int32_t i = 0; i < 11 - length; i++)
- encodeContents = wchar_t('0') + encodeContents;
+ encodeContents = L'0' + encodeContents;
ByteString byteString = encodeContents.ToUTF8();
int32_t checksum = pWriter->CalcChecksum(byteString);
- byteString += checksum - 0 + '0';
+ byteString += '0' + checksum;
encodeContents = WideString::FromUTF8(byteString.AsStringView());
}
if (length > 12)
diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter_unittest.cpp b/fxbarcode/oned/BC_OnedCodaBarWriter_unittest.cpp
index f498449..08ba718 100644
--- a/fxbarcode/oned/BC_OnedCodaBarWriter_unittest.cpp
+++ b/fxbarcode/oned/BC_OnedCodaBarWriter_unittest.cpp
@@ -8,13 +8,13 @@
namespace {
// 3 wide and 4 narrow modules per delimiter. One space between them.
-const int kModulesForDelimiters = (3 * 2 + 4 * 1) * 2 + 1;
+constexpr int kModulesForDelimiters = (3 * 2 + 4) * 2 + 1;
// 2 wide and 5 narrow modules per number, '_' or '$'. 1 space between chars.
-const int kModulesPerNumber = 2 * 2 + 5 * 1 + 1;
+constexpr int kModulesPerNumber = 2 * 2 + 5 + 1;
// 3 wide and 4 narrow modules per number, '_' or '$'. 1 space between chars.
-const int kModulesPerPunctuation = 3 * 2 + 4 * 1 + 1;
+constexpr int kModulesPerPunctuation = 3 * 2 + 4 + 1;
TEST(OnedCodaBarWriterTest, Encode) {
CBC_OnedCodaBarWriter writer;
diff --git a/fxbarcode/oned/BC_OnedCode39Writer_unittest.cpp b/fxbarcode/oned/BC_OnedCode39Writer_unittest.cpp
index 7a5f569..e20a607 100644
--- a/fxbarcode/oned/BC_OnedCode39Writer_unittest.cpp
+++ b/fxbarcode/oned/BC_OnedCode39Writer_unittest.cpp
@@ -10,7 +10,7 @@
namespace {
// 3 wide and 6 narrow modules per char. 1 space between chars.
-const int MODULES_PER_CHAR = 3 * 3 + 6 * 1 + 1;
+constexpr int MODULES_PER_CHAR = 3 * 3 + 6 + 1;
// '*' is added as the first and last char.
const int DELIMITER_CHARS = 2;