$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r76434 - sandbox/big_number/boost/multiprecision
From: john_at_[hidden]
Date: 2012-01-12 12:03:28
Author: johnmaddock
Date: 2012-01-12 12:03:27 EST (Thu, 12 Jan 2012)
New Revision: 76434
URL: http://svn.boost.org/trac/boost/changeset/76434
Log:
Optimize increment and decrement.
Text files modified: 
   sandbox/big_number/boost/multiprecision/fixed_int.hpp |    14 ++++++++++++--                          
   1 files changed, 12 insertions(+), 2 deletions(-)
Modified: sandbox/big_number/boost/multiprecision/fixed_int.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/fixed_int.hpp	(original)
+++ sandbox/big_number/boost/multiprecision/fixed_int.hpp	2012-01-12 12:03:27 EST (Thu, 12 Jan 2012)
@@ -424,13 +424,19 @@
 inline void increment(fixed_int<Bits, Signed>& result)
 {
    static const limb_type one = 1;
-   add(result, one);
+   if(result.data().elems[fixed_int<Bits, Signed>::limb_count - 1] < fixed_int<Bits, Signed>::max_limb_value)
+      ++result.data().elems[fixed_int<Bits, Signed>::limb_count - 1];
+   else
+      add(result, one);
 }
 template <unsigned Bits, bool Signed>
 inline void decrement(fixed_int<Bits, Signed>& result)
 {
    static const limb_type one = 1;
-   subtract(result, one);
+   if(result.data().elems[fixed_int<Bits, Signed>::limb_count - 1])
+      --result.data().elems[fixed_int<Bits, Signed>::limb_count - 1];
+   else
+      subtract(result, one);
 }
 template <unsigned Bits, bool Signed>
 inline void subtract(fixed_int<Bits, Signed>& result, const fixed_int<Bits, Signed>& o)
@@ -720,6 +726,8 @@
       return;
    }
 
+   //fixed_int<Bits, Signed> last_r;
+   //bool last_neg;
    do
    {
       //
@@ -731,6 +739,8 @@
       // Calculate our best guess for how many times y divides into r:
       //
       limb_type guess;
+      //last_r = r;
+      //last_neg = r_neg;
       if((r.data()[r_order] <= y.data()[y_order]) && (r_order < fixed_int<Bits, Signed>::limb_count - 1))
       {
          double_limb_type a, b, v;