mirror of
https://github.com/lua/lua
synced 2024-11-22 04:41:23 +03:00
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
Block a user