diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-01 17:33:49 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-01 17:33:49 +0000 |
commit | 673af68584b6ada36682c33acddfea2bcd749030 (patch) | |
tree | 3b75d42726768d9f7476802eb5415d7cb809281f /fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp | |
parent | 48ce3d08faa51bf00edaa3ae0afda9bf86e14a39 (diff) | |
download | pdfium-673af68584b6ada36682c33acddfea2bcd749030.tar.xz |
Remove some "exceptions" from reedsolomon code.
Change-Id: If8c45af624ed6df7b6d7416bb4e195f4097b0574
Reviewed-on: https://pdfium-review.googlesource.com/43191
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp')
-rw-r--r-- | fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp index 3f761054c4..a5657e1747 100644 --- a/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp +++ b/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp @@ -76,28 +76,22 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne() const { std::unique_ptr<CBC_ReedSolomonGF256Poly> CBC_ReedSolomonGF256::BuildMonomial( int32_t degree, - int32_t coefficient, - int32_t& e) { - if (degree < 0) { - e = BCExceptionDegreeIsNegative; + int32_t coefficient) { + if (degree < 0) return nullptr; - } - if (coefficient == 0) { - auto temp = m_zero->Clone(); - if (!temp) - e = BCExceptionGeneric; - return temp; - } + + if (coefficient == 0) + return m_zero->Clone(); + std::vector<int32_t> coefficients(degree + 1); coefficients[0] = coefficient; auto temp = pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>(); - if (!temp->Init(this, &coefficients)) { - e = BCExceptionGeneric; + if (!temp->Init(this, &coefficients)) return nullptr; - } return temp; } +// static int32_t CBC_ReedSolomonGF256::AddOrSubtract(int32_t a, int32_t b) { return a ^ b; } @@ -106,19 +100,9 @@ int32_t CBC_ReedSolomonGF256::Exp(int32_t a) { return m_expTable[a]; } -int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) { - if (a == 0) { - e = BCExceptionAIsZero; - return 0; - } - return m_logTable[a]; -} - -int32_t CBC_ReedSolomonGF256::Inverse(int32_t a, int32_t& e) { - if (a == 0) { - e = BCExceptionAIsZero; - return 0; - } +Optional<int32_t> CBC_ReedSolomonGF256::Inverse(int32_t a) { + if (a == 0) + return {}; return m_expTable[255 - m_logTable[a]]; } |