mirror of https://github.com/rusefi/lua.git
Optimization for 'n^2'
Squares are much more common than other exponentiations, and 'n*n' is much more efficient than 'pow'.
This commit is contained in:
parent
2f4162bc47
commit
9d067ab73b
|
@ -326,7 +326,8 @@ typedef l_uint32 Instruction;
|
|||
|
||||
/* exponentiation */
|
||||
#if !defined(luai_numpow)
|
||||
#define luai_numpow(L,a,b) ((void)L, l_mathop(pow)(a,b))
|
||||
#define luai_numpow(L,a,b) \
|
||||
((void)L, (b == 2) ? (a)*(a) : l_mathop(pow)(a,b))
|
||||
#endif
|
||||
|
||||
/* the others are quite standard operations */
|
||||
|
|
Loading…
Reference in New Issue