convert most variable swaps to mem swaps

This commit is contained in:
Henry Schimke
2022-12-19 18:04:43 -06:00
parent eaacf31923
commit 8a0cc78c61
11 changed files with 16 additions and 39 deletions

View File

@@ -85,9 +85,7 @@ impl Detector {
let mut bulls_eye_corners = self.get_bulls_eye_corners(p_center)?;
if is_mirror {
let temp = bulls_eye_corners[0];
bulls_eye_corners[0] = bulls_eye_corners[2];
bulls_eye_corners[2] = temp;
bulls_eye_corners.swap(0,2);
}
// 3. Get the size of the matrix and other parameters from the bull's eye

View File

@@ -214,9 +214,8 @@ impl GlobalHistogramBinarizer {
// Make sure firstPeak corresponds to the black peak.
if firstPeak > secondPeak {
let temp = firstPeak;
firstPeak = secondPeak;
secondPeak = temp;
std::mem::swap(&mut firstPeak, &mut secondPeak);
}
// If there is too little contrast in the image to pick a meaningful black point, throw rather

View File

@@ -154,9 +154,7 @@ impl GenericGFPoly {
let mut smallerCoefficients = self.coefficients.clone();
let mut largerCoefficients = other.coefficients.clone();
if smallerCoefficients.len() > largerCoefficients.len() {
let temp = smallerCoefficients;
smallerCoefficients = largerCoefficients;
largerCoefficients = temp;
std::mem::swap(&mut smallerCoefficients,&mut largerCoefficients)
}
let mut sumDiff = vec![0; largerCoefficients.len()];

View File

@@ -121,9 +121,7 @@ impl ReedSolomonDecoder {
let mut a = a.clone();
let mut b = b.clone();
if a.getDegree() < b.getDegree() {
let temp = a;
a = b;
b = temp;
std::mem::swap(&mut a, &mut b);
}
let mut rLast = a;

View File

@@ -840,9 +840,8 @@ impl RSSExpandedReader {
let mut j = counters.len() - 1;
while i < j {
// for (int i = 0, j = counters.length - 1; i < j; i++, j--) {
let temp = counters[i];
counters[i] = counters[j];
counters[j] = temp;
counters.swap(i, j);
i += 1;
j -= 1;

View File

@@ -307,9 +307,8 @@ impl RSS14Reader {
let mut j = counters.len() - 1;
while i < j {
// for (int i = 0, j = counters.length - 1; i < j; i++, j--) {
let temp = counters[i];
counters[i] = counters[j];
counters[j] = temp;
counters.swap(i,j);
i += 1;
j -= 1;

View File

@@ -124,9 +124,7 @@ fn runEuclideanAlgorithm(
let mut a = a;
let mut b = b;
if a.getDegree() < b.getDegree() {
let temp = a;
a = b;
b = temp;
std::mem::swap(&mut a,&mut b);
}
let mut rLast = a;

View File

@@ -139,9 +139,7 @@ impl ModulusPoly {
let mut smallerCoefficients = &self.coefficients;
let mut largerCoefficients = &other.coefficients;
if smallerCoefficients.len() > largerCoefficients.len() {
let temp = smallerCoefficients;
smallerCoefficients = largerCoefficients;
largerCoefficients = temp;
std::mem::swap(&mut smallerCoefficients, &mut largerCoefficients);
}
let mut sumDiff = vec![0032; largerCoefficients.len()];
let lengthDiff = largerCoefficients.len() - smallerCoefficients.len();

View File

@@ -230,9 +230,7 @@ impl PlanarYUVLuminanceSource {
let mut x2 = rowStart + width - 1;
for x1 in rowStart..middle {
//for (int x1 = rowStart, x2 = rowStart + width - 1; x1 < middle; x1++, x2--) {
let temp = self.yuv_data[x1];
self.yuv_data[x1] = self.yuv_data[x2];
self.yuv_data[x2] = temp;
self.yuv_data.swap(x1, x2);
x2 -= 1;
}
rowStart += self.data_width;

View File

@@ -767,9 +767,7 @@ impl FinderPatternFinder {
if a < b {
if b > c {
if a < c {
let temp = b;
b = c;
c = temp;
std::mem::swap(&mut b, &mut c)
} else {
let temp = a;
a = c;
@@ -780,9 +778,7 @@ impl FinderPatternFinder {
} else {
if b < c {
if a < c {
let temp = a;
a = b;
b = temp;
std::mem::swap(&mut a, &mut b)
} else {
let temp = a;
a = b;
@@ -790,9 +786,7 @@ impl FinderPatternFinder {
c = temp;
}
} else {
let temp = a;
a = c;
c = temp;
std::mem::swap(&mut a, &mut c);
}
}

View File

@@ -50,9 +50,7 @@ pub fn orderBestPatterns<T: ResultPoint + Copy + Clone>(patterns: &mut [T; 3]) {
// we want for A, B, C. If it's negative, then we've got it flipped around and
// should swap A and C.
if crossProductZ(pointA, pointB, pointC) < 0.0f32 {
let temp = pointA;
pointA = pointC;
pointC = temp;
std::mem::swap(&mut pointA, &mut pointC);
}
let pa = pointA;