diff options
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]]; } |