From 6b48994596e469afc4e731efd624b04f7a40a6cf Mon Sep 17 00:00:00 2001 From: Kp Date: Mon, 25 Jun 2012 02:16:10 +0000 Subject: [PATCH] Avoid unnecessary lookups in fix_sincos --- common/maths/fixc.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/common/maths/fixc.cpp b/common/maths/fixc.cpp index c9c020611..842e3ef14 100644 --- a/common/maths/fixc.cpp +++ b/common/maths/fixc.cpp @@ -258,16 +258,21 @@ fix fix_sqrt(fix a) void fix_sincos(fix a,fix *s,fix *c) { int i,f; - fix ss,cc; i = (a>>8)&0xff; f = a&0xff; - ss = sincos_table[i]; - if (s) *s = (ss + (((sincos_table[i+1] - ss) * f)>>8))<<2; + if (s) + { + fix ss = sincos_table[i]; + *s = (ss + (((sincos_table[i+1] - ss) * f)>>8))<<2; + } - cc = sincos_table[i+64]; - if (c) *c = (cc + (((sincos_table[i+64+1] - cc) * f)>>8))<<2; + if (c) + { + fix cc = sincos_table[i+64]; + *c = (cc + (((sincos_table[i+64+1] - cc) * f)>>8))<<2; + } } //compute sine and cosine of an angle, filling in the variables