Browse Source

Math: don't zero-initialize output variables if not necessary.

Could possibly save some cycles.
pull/179/head
Vladimír Vondruš 10 years ago
parent
commit
3764f5b830
  1. 4
      src/Magnum/Math/Matrix.h
  2. 6
      src/Magnum/Math/RectangularMatrix.h

4
src/Magnum/Math/Matrix.h

@ -333,7 +333,7 @@ template<std::size_t size, class T> bool Matrix<size, T>::isOrthogonal() const {
} }
template<std::size_t size, class T> Matrix<size-1, T> Matrix<size, T>::ij(const std::size_t skipCol, const std::size_t skipRow) const { template<std::size_t size, class T> Matrix<size-1, T> Matrix<size, T>::ij(const std::size_t skipCol, const std::size_t skipRow) const {
Matrix<size-1, T> out{ZeroInit}; Matrix<size-1, T> out{NoInit};
for(std::size_t col = 0; col != size-1; ++col) for(std::size_t col = 0; col != size-1; ++col)
for(std::size_t row = 0; row != size-1; ++row) for(std::size_t row = 0; row != size-1; ++row)
@ -344,7 +344,7 @@ template<std::size_t size, class T> Matrix<size-1, T> Matrix<size, T>::ij(const
} }
template<std::size_t size, class T> Matrix<size, T> Matrix<size, T>::inverted() const { template<std::size_t size, class T> Matrix<size, T> Matrix<size, T>::inverted() const {
Matrix<size, T> out{ZeroInit}; Matrix<size, T> out{NoInit};
const T _determinant = determinant(); const T _determinant = determinant();

6
src/Magnum/Math/RectangularMatrix.h

@ -523,7 +523,7 @@ template<std::size_t cols, std::size_t rows, class T> inline RectangularMatrix<c
#endif #endif
number, const RectangularMatrix<cols, rows, T>& matrix) number, const RectangularMatrix<cols, rows, T>& matrix)
{ {
RectangularMatrix<cols, rows, T> out; RectangularMatrix<cols, rows, T> out{NoInit};
for(std::size_t i = 0; i != cols; ++i) for(std::size_t i = 0; i != cols; ++i)
out[i] = number/matrix[i]; out[i] = number/matrix[i];
@ -687,7 +687,7 @@ template<std::size_t cols, std::size_t rows, class T> inline RectangularMatrix<c
} }
template<std::size_t cols, std::size_t rows, class T> template<std::size_t size> inline RectangularMatrix<size, rows, T> RectangularMatrix<cols, rows, T>::operator*(const RectangularMatrix<size, cols, T>& other) const { template<std::size_t cols, std::size_t rows, class T> template<std::size_t size> inline RectangularMatrix<size, rows, T> RectangularMatrix<cols, rows, T>::operator*(const RectangularMatrix<size, cols, T>& other) const {
RectangularMatrix<size, rows, T> out; RectangularMatrix<size, rows, T> out{ZeroInit};
for(std::size_t col = 0; col != size; ++col) for(std::size_t col = 0; col != size; ++col)
for(std::size_t row = 0; row != rows; ++row) for(std::size_t row = 0; row != rows; ++row)
@ -698,7 +698,7 @@ template<std::size_t cols, std::size_t rows, class T> template<std::size_t size>
} }
template<std::size_t cols, std::size_t rows, class T> inline RectangularMatrix<rows, cols, T> RectangularMatrix<cols, rows, T>::transposed() const { template<std::size_t cols, std::size_t rows, class T> inline RectangularMatrix<rows, cols, T> RectangularMatrix<cols, rows, T>::transposed() const {
RectangularMatrix<rows, cols, T> out; RectangularMatrix<rows, cols, T> out{NoInit};
for(std::size_t col = 0; col != cols; ++col) for(std::size_t col = 0; col != cols; ++col)
for(std::size_t row = 0; row != rows; ++row) for(std::size_t row = 0; row != rows; ++row)

Loading…
Cancel
Save