diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index e8408997..af3c68aa 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -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 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 -- diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index fed82bf6..ec415164 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -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 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 -- diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 66539e30..78a9ce6d 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -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 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 --