performance improvements

This commit is contained in:
Eduardo Bart
2012-06-05 12:36:27 -03:00
parent 4de9787198
commit 023a4ebef6
19 changed files with 65 additions and 31 deletions

View File

@@ -68,7 +68,7 @@ public:
int getUseCount();
/// Returns the derived class name, its the same name used in Lua
virtual std::string getClassName() const {
std::string getClassName() const {
// TODO: this could be cached for more performance
return stdext::demangle_name(typeid(*this).name());
}

View File

@@ -170,11 +170,7 @@ bool Matrix<N,M,T>::operator==(const Matrix<N,M,T>& other) const
template<int N, int M, typename T>
bool Matrix<N,M,T>::operator!=(const Matrix<N,M,T>& other) const
{
for(int i=0;i<N;++i)
for(int j=0;j<M;++j)
if(m[i][j] != other.m[i][j])
return true;
return false;
return !(*this == other);
}
template<int N, int M, typename T>
@@ -200,6 +196,17 @@ std::istream& operator>>(std::istream& in, Matrix<N,M,T>& mat)
return in;
}
// faster comparing for 3x3 matrixes
template<>
inline bool Matrix<3,3,float>::operator==(const Matrix<3,3,float>& other) const
{
return m[0][0] == other.m[0][0] && m[1][1] == other.m[1][1] &&
m[2][1] == other.m[2][1] && m[2][0] == other.m[2][0] &&
m[1][2] == other.m[1][2] && m[0][2] == other.m[0][2] &&
m[1][0] == other.m[1][0] && m[0][1] == other.m[0][1] &&
m[2][2] == other.m[2][2];
}
typedef Matrix<4,4> Matrix4x4;
typedef Matrix<3,3> Matrix3x3;
typedef Matrix<2,2> Matrix2x2;