aboutsummaryrefslogtreecommitdiff
path: root/llimits.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-11-13 09:59:07 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-11-13 09:59:07 -0300
commit9d067ab73b6befa0a5418f1df35c711f6c6918b3 (patch)
tree250093c32a8b0575c8c47aced1bdbb7d3d7bc3fd /llimits.h
parent2f4162bc473b995117e95c88230f637ca3e1c866 (diff)
downloadlua-5.4.2.tar.gz
lua-5.4.2.tar.bz2
lua-5.4.2.zip
Optimization for 'n^2'v5.4.2
Squares are much more common than other exponentiations, and 'n*n' is much more efficient than 'pow'.
Diffstat (limited to 'llimits.h')
-rw-r--r--llimits.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/llimits.h b/llimits.h
index a76c13ed..d0394831 100644
--- a/llimits.h
+++ b/llimits.h
@@ -326,7 +326,8 @@ typedef l_uint32 Instruction;
326 326
327/* exponentiation */ 327/* exponentiation */
328#if !defined(luai_numpow) 328#if !defined(luai_numpow)
329#define luai_numpow(L,a,b) ((void)L, l_mathop(pow)(a,b)) 329#define luai_numpow(L,a,b) \
330 ((void)L, (b == 2) ? (a)*(a) : l_mathop(pow)(a,b))
330#endif 331#endif
331 332
332/* the others are quite standard operations */ 333/* the others are quite standard operations */