mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 04:42:35 +00:00
remove .to_owned() calls on &str in exceptions
This commit is contained in:
@@ -141,7 +141,7 @@ impl GenericGFPoly {
|
||||
pub fn addOrSubtract(&self, other: &GenericGFPoly) -> Result<GenericGFPoly, Exceptions> {
|
||||
if self.field != other.field {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"GenericGFPolys do not have same GenericGF field".to_owned(),
|
||||
"GenericGFPolys do not have same GenericGF field",
|
||||
));
|
||||
}
|
||||
if self.isZero() {
|
||||
@@ -178,7 +178,7 @@ impl GenericGFPoly {
|
||||
if self.field != other.field {
|
||||
//if (!field.equals(other.field)) {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"GenericGFPolys do not have same GenericGF field".to_owned(),
|
||||
"GenericGFPolys do not have same GenericGF field",
|
||||
));
|
||||
}
|
||||
if self.isZero() || other.isZero() {
|
||||
@@ -253,11 +253,11 @@ impl GenericGFPoly {
|
||||
) -> Result<(GenericGFPoly, GenericGFPoly), Exceptions> {
|
||||
if self.field != other.field {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"GenericGFPolys do not have same GenericGF field".to_owned(),
|
||||
"GenericGFPolys do not have same GenericGF field",
|
||||
));
|
||||
}
|
||||
if other.isZero() {
|
||||
return Err(Exceptions::illegalArgument("Divide by 0".to_owned()));
|
||||
return Err(Exceptions::illegalArgument("Divide by 0"));
|
||||
}
|
||||
|
||||
let mut quotient = self.getZero();
|
||||
@@ -266,7 +266,7 @@ impl GenericGFPoly {
|
||||
let denominator_leading_term = other.getCoefficient(other.getDegree());
|
||||
let inverse_denominator_leading_term = match self.field.inverse(denominator_leading_term) {
|
||||
Ok(val) => val,
|
||||
Err(_issue) => return Err(Exceptions::illegalArgument("arithmetic issue".to_owned())),
|
||||
Err(_issue) => return Err(Exceptions::illegalArgument("arithmetic issue")),
|
||||
};
|
||||
|
||||
while remainder.getDegree() >= other.getDegree() && !remainder.isZero() {
|
||||
|
||||
@@ -92,11 +92,11 @@ impl ReedSolomonDecoder {
|
||||
//for (int i = 0; i < errorLocations.length; i++) {
|
||||
let log_value = self.field.log(errorLocations[i] as i32)?;
|
||||
if log_value > received.len() as i32 - 1 {
|
||||
return Err(Exceptions::reedSolomon("Bad error location".to_owned()));
|
||||
return Err(Exceptions::reedSolomon("Bad error location"));
|
||||
}
|
||||
let position: isize = received.len() as isize - 1 - log_value as isize;
|
||||
if position < 0 {
|
||||
return Err(Exceptions::reedSolomon("Bad error location".to_owned()));
|
||||
return Err(Exceptions::reedSolomon("Bad error location"));
|
||||
}
|
||||
received[position as usize] =
|
||||
GenericGF::addOrSubtract(received[position as usize], errorMagnitudes[i]);
|
||||
@@ -134,7 +134,7 @@ impl ReedSolomonDecoder {
|
||||
// Divide rLastLast by rLast, with quotient in q and remainder in r
|
||||
if rLast.isZero() {
|
||||
// Oops, Euclidean algorithm already terminated?
|
||||
return Err(Exceptions::reedSolomon("r_{i-1} was zero".to_owned()));
|
||||
return Err(Exceptions::reedSolomon("r_{i-1} was zero"));
|
||||
}
|
||||
r = rLastLast;
|
||||
let mut q = r.getZero();
|
||||
@@ -160,12 +160,12 @@ impl ReedSolomonDecoder {
|
||||
|
||||
let sigmaTildeAtZero = t.getCoefficient(0);
|
||||
if sigmaTildeAtZero == 0 {
|
||||
return Err(Exceptions::reedSolomon("sigmaTilde(0) was zero".to_owned()));
|
||||
return Err(Exceptions::reedSolomon("sigmaTilde(0) was zero"));
|
||||
}
|
||||
|
||||
let inverse = match self.field.inverse(sigmaTildeAtZero) {
|
||||
Ok(res) => res,
|
||||
Err(_err) => return Err(Exceptions::reedSolomon("ArithmetricException".to_owned())),
|
||||
Err(_err) => return Err(Exceptions::reedSolomon("ArithmetricException")),
|
||||
};
|
||||
let sigma = t.multiply_with_scalar(inverse);
|
||||
let omega = r.multiply_with_scalar(inverse);
|
||||
@@ -194,7 +194,7 @@ impl ReedSolomonDecoder {
|
||||
}
|
||||
if e != numErrors {
|
||||
return Err(Exceptions::reedSolomon(
|
||||
"Error locator degree does not match number of roots".to_owned(),
|
||||
"Error locator degree does not match number of roots",
|
||||
));
|
||||
}
|
||||
Ok(result)
|
||||
|
||||
@@ -73,15 +73,11 @@ impl ReedSolomonEncoder {
|
||||
|
||||
pub fn encode(&mut self, to_encode: &mut Vec<i32>, ec_bytes: usize) -> Result<(), Exceptions> {
|
||||
if ec_bytes == 0 {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"No error correction bytes".to_owned(),
|
||||
));
|
||||
return Err(Exceptions::illegalArgument("No error correction bytes"));
|
||||
}
|
||||
let data_bytes = to_encode.len() - ec_bytes;
|
||||
if data_bytes == 0 {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"No data bytes provided".to_owned(),
|
||||
));
|
||||
return Err(Exceptions::illegalArgument("No data bytes provided"));
|
||||
}
|
||||
let fld = self.field;
|
||||
let generator = self.buildGenerator(ec_bytes);
|
||||
|
||||
Reference in New Issue
Block a user