From cf4a36aeff5b881d5f39576c48388df0c28f2d9e Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 1 Feb 2015 23:07:18 +0000 Subject: [PATCH] Optimize quad_sqrt masking --- common/maths/fixc.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/common/maths/fixc.cpp b/common/maths/fixc.cpp index 758c65bf7..1246ae136 100644 --- a/common/maths/fixc.cpp +++ b/common/maths/fixc.cpp @@ -102,12 +102,16 @@ u_int32_t quad_sqrt(const quadint iq) if (high==0 && (int32_t)low>=0) return long_sqrt((int32_t)low); - if (high & 0xff000000) { - cnt=12+16; i = high >> 24; - } else if (high & 0xff0000) { - cnt=8+16; i = high >> 16; - } else if (high & 0xff00) { - cnt=4+16; i = high >> 8; + if ((i = high >> 24)) { + cnt=12+16; + } + else if ((i = high >> 16)) + { + cnt=8+16; + } + else if ((i = high >> 8)) + { + cnt=4+16; } else { cnt=0+16; i = high; }