gmpxx patch: remove some copying

Marc Glisse marc.glisse at
Wed Sep 3 16:12:46 CEST 2008

On Tue, 2 Sep 2008, Marc Glisse wrote:

> I am not changing the mpf case because it might interfere with the way 
> the precision is set (I am not sure so I don't want to take risks).

For mpf, the patch is:

    void eval(typename __gmp_resolve_expr<T>::ptr_type p,
             unsigned long int prec) const
-  { __gmp_expr<T, T> temp(expr.val, prec); Op::eval(p, temp.__get_mp()); }
+  { expr.val.eval(p, prec); Op::eval(p, p); }
    const val_type & get_val() const { return expr.val; }
    unsigned long int get_prec() const { return expr.val.get_prec(); }

I actually believe it is safe, but it would require confirmation by 
someone else. It passes the testsuite but we all know that is not a 

Marc Glisse

More information about the gmp-bugs mailing list