mirror of
https://github.com/g-truc/glm.git
synced 2025-04-05 05:25:02 +00:00
optimize vector component access
This commit is contained in:
parent
33b4a621a6
commit
f6230f8869
3 changed files with 6 additions and 60 deletions
|
@ -106,28 +106,14 @@ namespace glm
|
|||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T & vec<2, T, Q>::operator[](typename vec<2, T, Q>::length_type i)
|
||||
{
|
||||
GLM_ASSERT_LENGTH(i, this->length());
|
||||
switch(i)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
}
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& vec<2, T, Q>::operator[](typename vec<2, T, Q>::length_type i) const
|
||||
{
|
||||
GLM_ASSERT_LENGTH(i, this->length());
|
||||
switch(i)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
}
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
// -- Unary arithmetic operators --
|
||||
|
|
|
@ -171,32 +171,14 @@ namespace glm
|
|||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T & vec<3, T, Q>::operator[](typename vec<3, T, Q>::length_type i)
|
||||
{
|
||||
GLM_ASSERT_LENGTH(i, this->length());
|
||||
switch(i)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
case 2:
|
||||
return z;
|
||||
}
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& vec<3, T, Q>::operator[](typename vec<3, T, Q>::length_type i) const
|
||||
{
|
||||
GLM_ASSERT_LENGTH(i, this->length());
|
||||
switch(i)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
case 2:
|
||||
return z;
|
||||
}
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
// -- Unary arithmetic operators --
|
||||
|
|
|
@ -362,36 +362,14 @@ namespace detail
|
|||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T& vec<4, T, Q>::operator[](typename vec<4, T, Q>::length_type i)
|
||||
{
|
||||
GLM_ASSERT_LENGTH(i, this->length());
|
||||
switch (i)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
case 2:
|
||||
return z;
|
||||
case 3:
|
||||
return w;
|
||||
}
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& vec<4, T, Q>::operator[](typename vec<4, T, Q>::length_type i) const
|
||||
{
|
||||
GLM_ASSERT_LENGTH(i, this->length());
|
||||
switch (i)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
case 2:
|
||||
return z;
|
||||
case 3:
|
||||
return w;
|
||||
}
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
// -- Unary arithmetic operators --
|
||||
|
|
Loading…
Add table
Reference in a new issue