-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Add memcpy and const #36
base: master
Are you sure you want to change the base?
Conversation
Use memcpy (which might be faster depending on the platform being used) and use 'const' for elements not being modified in functions
@@ -1328,15 +1329,15 @@ mfloat_t *vec3_clamp(mfloat_t *result, mfloat_t *v0, mfloat_t *v1, mfloat_t *v2) | |||
return result; | |||
} | |||
|
|||
mfloat_t *vec3_cross(mfloat_t *result, mfloat_t *v0, mfloat_t *v1) | |||
mfloat_t *vec3_cross(mfloat_t *result, const mfloat_t *v0, const mfloat_t *v1) | |||
{ | |||
mfloat_t cross[VEC3_SIZE]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this specific case the local variable cross[] is not nessary and the results can directly be written into result[]
Hi, sorry for the late response, I was traveling and taking care of changes in life. Some operations mix components, such as rotation, which means a buffer is necessary for them. I decided to keep a style that is consistent across the entire library, which allows to do this without worrying:
I think |
Maybe you can provide a simple
Then use |
Wouldn't even embedded targets with very restricted libc's usually have |
With Microsoft compiler, you can avoid the use of any CRT by just defining |
Use memcpy (which might be faster depending on the platform being used) and use 'const' for elements not being modified in functions.
This is proof-of-concept diff, of course the function prototype in mathc.h needs to be modified as well, and it requires a rewrite of other functions as well.