From: David Flynn <[EMAIL PROTECTED]>

Iterating a loop that shifts n count times and then adding 1<<count
can be done by initializing n to 1.

Signed-off-by: David Flynn <[EMAIL PROTECTED]>
---
 schroedinger/schroarith.c |   10 ++++------
 schroedinger/schroarith.h |    5 ++---
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/schroedinger/schroarith.c b/schroedinger/schroarith.c
index 7341926..3d7d34b 100644
--- a/schroedinger/schroarith.c
+++ b/schroedinger/schroarith.c
@@ -543,10 +543,9 @@ int
 _schro_arith_decode_uint (SchroArith *arith, unsigned int cont_context,
     unsigned int value_context)
 {
-  int bits;
+  unsigned int bits=1;
   int count=0;
 
-  bits = 0;
   while(!__schro_arith_decode_bit (arith, cont_context)) {
     bits <<= 1;
     bits |= __schro_arith_decode_bit (arith, value_context);
@@ -556,7 +555,7 @@ _schro_arith_decode_uint (SchroArith *arith, unsigned int 
cont_context,
     /* FIXME being careful */
     if (count == 30) break;
   }
-  return (1<<count) - 1 + bits;
+  return bits - 1;
 }
 #endif
 
@@ -564,11 +563,10 @@ int
 _schro_arith_decode_sint (SchroArith *arith, unsigned int cont_context,
     unsigned int value_context, unsigned int sign_context)
 {
-  int bits;
+  unsigned int bits=1;
   int count=0;
   int value;
 
-  bits = 0;
   while(!_schro_arith_decode_bit (arith, cont_context)) {
     bits <<= 1;
     bits |= _schro_arith_decode_bit (arith, value_context);
@@ -578,7 +576,7 @@ _schro_arith_decode_sint (SchroArith *arith, unsigned int 
cont_context,
     /* FIXME being careful */
     if (count == 30) break;
   }
-  value = (1<<count) - 1 + bits;
+  value = bits - 1;
 
   if (value) {
     if (_schro_arith_decode_bit (arith, sign_context)) {
diff --git a/schroedinger/schroarith.h b/schroedinger/schroarith.h
index 43950b1..6a5a848 100644
--- a/schroedinger/schroarith.h
+++ b/schroedinger/schroarith.h
@@ -201,10 +201,9 @@ static int
 _schro_arith_decode_uint (SchroArith *arith, unsigned int cont_context,
     unsigned int value_context)
 {
-  int bits;
+  unsigned int bits=1;
   int count=0;
 
-  bits = 0;
   while(!_schro_arith_decode_bit (arith, cont_context)) {
     bits <<= 1;
     bits |= _schro_arith_decode_bit (arith, value_context);
@@ -214,7 +213,7 @@ _schro_arith_decode_uint (SchroArith *arith, unsigned int 
cont_context,
     /* FIXME being careful */
     if (count == 30) break;
   }
-  return (1<<count) - 1 + bits;
+  return bits - 1;
 }
 #endif
 
-- 
1.5.5




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Schrodinger-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/schrodinger-devel

Reply via email to