Optimize column swapping logic to handle empty matrices and prevent unnecessary swaps

This commit is contained in:
Palash Tyagi 2025-05-03 00:29:14 +01:00
parent 9fd3582061
commit 4c02006153

View File

@ -148,12 +148,7 @@ impl<T: Clone> Matrix<T> {
c2, c2,
self.cols self.cols
); );
if c1 == c2 { if c1 == c2 || self.rows == 0 || self.cols == 0 {
return;
}
if self.rows == 0 {
self.data.swap(c1, c2);
return; return;
} }