mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
cleanup
This commit is contained in:
@@ -22,7 +22,6 @@ use std::{cmp, fmt};
|
||||
|
||||
use crate::Exceptions;
|
||||
|
||||
static EMPTY_BITS: [u32; 0] = [0; 0];
|
||||
static LOAD_FACTOR: f32 = 0.75f32;
|
||||
|
||||
/**
|
||||
@@ -39,7 +38,7 @@ pub struct BitArray {
|
||||
impl BitArray {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
bits: EMPTY_BITS.to_vec(),
|
||||
bits: Vec::new(),
|
||||
size: 0,
|
||||
}
|
||||
}
|
||||
@@ -327,7 +326,7 @@ impl BitArray {
|
||||
* @return underlying array of ints. The first element holds the first 32 bits, and the least
|
||||
* significant bit is bit 0.
|
||||
*/
|
||||
pub fn getBitArray(&self) -> &Vec<u32> {
|
||||
pub fn getBitArray(&self) -> &[u32] {
|
||||
&self.bits
|
||||
}
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ impl BitMatrix {
|
||||
Ok(((self.bits[offset] >> (x & 0x1f)) & 1) != 0)
|
||||
}
|
||||
|
||||
/// Confusingly returns true if the requested element is out of bounds
|
||||
pub fn check_in_bounds(&self, x: u32, y: u32) -> bool {
|
||||
(y as usize * self.row_size + (x as usize / 32)) > self.bits.len()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ use super::{BitArray, BitMatrix};
|
||||
* @author Sean Owen
|
||||
*/
|
||||
pub struct GlobalHistogramBinarizer {
|
||||
_luminances: Vec<u8>,
|
||||
//_luminances: Vec<u8>,
|
||||
width: usize,
|
||||
height: usize,
|
||||
source: Box<dyn LuminanceSource>,
|
||||
@@ -134,7 +134,7 @@ impl GlobalHistogramBinarizer {
|
||||
|
||||
pub fn new(source: Box<dyn LuminanceSource>) -> Self {
|
||||
Self {
|
||||
_luminances: vec![0; source.getWidth()],
|
||||
//_luminances: vec![0; source.getWidth()],
|
||||
width: source.getWidth(),
|
||||
height: source.getHeight(),
|
||||
black_matrix: OnceCell::new(),
|
||||
|
||||
@@ -47,7 +47,7 @@ impl GenericGFPoly {
|
||||
* or if leading coefficient is 0 and this is not a
|
||||
* constant polynomial (that is, it is not the monomial "0")
|
||||
*/
|
||||
pub fn new(field: GenericGFRef, coefficients: &Vec<i32>) -> Result<Self, Exceptions> {
|
||||
pub fn new(field: GenericGFRef, coefficients: &[i32]) -> Result<Self, Exceptions> {
|
||||
if coefficients.is_empty() {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(
|
||||
"coefficients.len()".to_owned(),
|
||||
|
||||
@@ -76,9 +76,8 @@ impl ReedSolomonDecoder {
|
||||
if noError {
|
||||
return Ok(0);
|
||||
}
|
||||
let syndrome = match GenericGFPoly::new(self.field, &syndromeCoefficients) {
|
||||
Ok(res) => res,
|
||||
Err(_fail) => return Err(Exceptions::ReedSolomonException(None)),
|
||||
let Ok(syndrome) = GenericGFPoly::new(self.field, &syndromeCoefficients) else {
|
||||
return Err(Exceptions::ReedSolomonException(None));
|
||||
};
|
||||
let sigmaOmega = self.runEuclideanAlgorithm(
|
||||
&GenericGF::buildMonomial(self.field, twoS as usize, 1),
|
||||
|
||||
@@ -38,7 +38,7 @@ impl ReedSolomonEncoder {
|
||||
pub fn new(field: GenericGFRef) -> Self {
|
||||
let n = field;
|
||||
Self {
|
||||
cachedGenerators: vec![GenericGFPoly::new(n, &vec![1]).unwrap()],
|
||||
cachedGenerators: vec![GenericGFPoly::new(n, &[1]).unwrap()],
|
||||
field: n,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,20 +71,21 @@ impl StringUtils {
|
||||
* "SJIS", "UTF8", "ISO8859_1", or the platform default encoding if none
|
||||
* of these can possibly be correct
|
||||
*/
|
||||
pub fn guessEncoding(bytes: &[u8], hints: &DecodingHintDictionary) -> String {
|
||||
pub fn guessEncoding(bytes: &[u8], hints: &DecodingHintDictionary) -> &'static str {
|
||||
let c = StringUtils::guessCharset(bytes, hints);
|
||||
if c.name()
|
||||
== encoding::label::encoding_from_whatwg_label("SJIS")
|
||||
.unwrap()
|
||||
.name()
|
||||
{
|
||||
return "SJIS".to_owned();
|
||||
"SJIS"
|
||||
} else if c.name() == encoding::all::UTF_8.name() {
|
||||
return "UTF8".to_owned();
|
||||
"UTF8"
|
||||
} else if c.name() == encoding::all::ISO_8859_1.name() {
|
||||
return "ISO8859_1".to_owned();
|
||||
"ISO8859_1"
|
||||
}else {
|
||||
c.name()
|
||||
}
|
||||
return c.name().to_owned();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user