mirror of
https://github.com/lua/lua
synced 2024-11-25 14:20:41 +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 */
|
/* exponentiation */
|
||||||
#if !defined(luai_numpow)
|
#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
|
#endif
|
||||||
|
|
||||||
/* the others are quite standard operations */
|
/* the others are quite standard operations */
|
||||||
|
Loading…
Reference in New Issue
Block a user