From 5bf727dbd5aa2b997bdc5f1c1e3b3967b8568a50 Mon Sep 17 00:00:00 2001 From: Zak Strange Date: Thu, 29 Nov 2018 09:32:12 -0800 Subject: [PATCH] Removed copy in operator[] (#93) * Removed copy in operator[] * Updated version info --- HandmadeMath.h | 15 +++++++++------ README.md | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/HandmadeMath.h b/HandmadeMath.h index b0c6f5c..0e1b91a 100644 --- a/HandmadeMath.h +++ b/HandmadeMath.h @@ -1,5 +1,5 @@ /* - HandmadeMath.h v1.7.0 + HandmadeMath.h v1.7.1 This is a single header file with a bunch of useful functions for game and graphics math operations. @@ -176,7 +176,10 @@ (*) Renamed the 'Rows' member of hmm_mat4 to 'Columns'. Since our matrices are column-major, this should have been named 'Columns' from the start. 'Rows' is still present, but has been deprecated. - + 1.7.1 + (*) Changed operator[] to take in a const ref int instead of a int. + Simple dumb mistake. NOTE: The compiler still wont inline operator[] + for some reason LICENSE @@ -324,7 +327,7 @@ typedef union hmm_vec2 float Elements[2]; #ifdef __cplusplus - inline float &operator[](int Index) + inline float &operator[](const int &Index) { return Elements[Index]; } @@ -375,7 +378,7 @@ typedef union hmm_vec3 float Elements[3]; #ifdef __cplusplus - inline float &operator[](int Index) + inline float &operator[](const int &Index) { return Elements[Index]; } @@ -439,7 +442,7 @@ typedef union hmm_vec4 #endif #ifdef __cplusplus - inline float &operator[](int Index) + inline float &operator[](const int &Index) { return Elements[Index]; } @@ -459,7 +462,7 @@ typedef union hmm_mat4 #endif #ifdef __cplusplus - inline hmm_vec4 operator[](const int Index) + inline hmm_vec4 operator[](const int &Index) { float* col = Elements[Index]; diff --git a/README.md b/README.md index 3b5bbe2..167dafd 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ To get started, go download [the latest release](https://github.com/HandmadeMath Version | Changes | ----------------|----------------| +**1.7.1** | Changed operator[] to take in a const ref int instead of a int. Simple mistake **1.7.0** | Renamed the 'Rows' member of hmm_mat4 to 'Columns'. Since our matrices are column-major, this should have been named 'Columns' from the start. 'Rows' is still present, but has been deprecated. **1.6.0** | Added array subscript operators for vector and matrix types in C++. This is provided as a convenience, but be aware that it may incur an extra function call in unoptimized builds. **1.5.1** | Fixed a bug with uninitialized elements in HMM_LookAt.