mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
switch bitmatrix row fetch to skip usless clone
This commit is contained in:
@@ -151,17 +151,17 @@ fn test_get_row() {
|
||||
}
|
||||
|
||||
// Should allocate
|
||||
let array = matrix.getRow(2, &BitArray::new());
|
||||
let array = matrix.getRow(2, BitArray::new());
|
||||
assert_eq!(102, array.getSize());
|
||||
|
||||
// Should reallocate
|
||||
let mut array2 = BitArray::with_size(60);
|
||||
array2 = matrix.getRow(2, &array2);
|
||||
array2 = matrix.getRow(2, array2);
|
||||
assert_eq!(102, array2.getSize());
|
||||
|
||||
// Should use provided object, with original BitArray size
|
||||
let mut array3 = BitArray::with_size(200);
|
||||
array3 = matrix.getRow(2, &array3);
|
||||
array3 = matrix.getRow(2, array3);
|
||||
assert_eq!(200, array3.getSize());
|
||||
|
||||
for x in 0..102 {
|
||||
|
||||
@@ -254,12 +254,12 @@ impl BitMatrix {
|
||||
"input matrix dimensions do not match".to_owned(),
|
||||
));
|
||||
}
|
||||
let rowArray = BitArray::with_size(self.width as usize);
|
||||
let mut rowArray = BitArray::with_size(self.width as usize);
|
||||
for y in 0..self.height {
|
||||
//for (int y = 0; y < height; y++) {
|
||||
let offset = y as usize * self.row_size;
|
||||
let tmp = mask.getRow(y, &rowArray);
|
||||
let row = tmp.getBitArray();
|
||||
rowArray = mask.getRow(y, rowArray);
|
||||
let row = rowArray.getBitArray();
|
||||
for x in 0..self.row_size {
|
||||
//for (int x = 0; x < rowSize; x++) {
|
||||
self.bits[offset + x] ^= row[x];
|
||||
@@ -330,11 +330,11 @@ impl BitMatrix {
|
||||
* @return The resulting BitArray - this reference should always be used even when passing
|
||||
* your own row
|
||||
*/
|
||||
pub fn getRow(&self, y: u32, row: &BitArray) -> BitArray {
|
||||
pub fn getRow(&self, y: u32, row: BitArray) -> BitArray {
|
||||
let mut rw: BitArray = if row.getSize() < self.width as usize {
|
||||
BitArray::with_size(self.width as usize)
|
||||
} else {
|
||||
let mut z = row.clone();
|
||||
let mut z = row; //row.clone();
|
||||
z.clear();
|
||||
z
|
||||
// row.clear();
|
||||
@@ -395,9 +395,9 @@ impl BitMatrix {
|
||||
let maxHeight = (self.height + 1) / 2;
|
||||
for i in 0..maxHeight {
|
||||
//for (int i = 0; i < maxHeight; i++) {
|
||||
topRow = self.getRow(i, &topRow);
|
||||
topRow = self.getRow(i, topRow);
|
||||
let bottomRowIndex = self.height - 1 - i;
|
||||
bottomRow = self.getRow(bottomRowIndex, &bottomRow);
|
||||
bottomRow = self.getRow(bottomRowIndex, bottomRow);
|
||||
topRow.reverse();
|
||||
bottomRow.reverse();
|
||||
self.setRow(i, &bottomRow);
|
||||
|
||||
@@ -412,7 +412,7 @@ mod code_39_extended_mode_test_case {
|
||||
let matrix =
|
||||
BitMatrix::parse_strings(encodedRXingResult, "1", "0").expect("bitmatrix parse");
|
||||
let row = BitArray::with_size(matrix.getWidth() as usize);
|
||||
let row = matrix.getRow(0, &row);
|
||||
let row = matrix.getRow(0, row);
|
||||
let result = sut.decodeRow(0, &row, &HashMap::new()).expect("decode row");
|
||||
assert_eq!(expectedRXingResult, result.getText());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user