gmpxx patch: remove some copying

Marc Glisse marc.glisse at normalesup.org
Tue Sep 2 18:26:28 CEST 2008


On Tue, 2 Sep 2008, Marc Glisse wrote:

> a small (3 lines) patch proposition

Hmm, the patch got corrupted somehow, here is (hopefully) a valid one.

-- 
Marc Glisse
-------------- next part --------------
--- /usr/include/gmpxx.h	2008-04-09 08:42:55.000000000 +0200
+++ gmpxx.h	2008-09-02 18:24:20.032951221 +0200
@@ -2092,8 +2092,8 @@
 template <class T>
 inline void __gmp_set_expr(mpq_ptr q, const __gmp_expr<mpz_t, T> &expr)
 {
-  mpz_class temp(expr);
-  mpq_set_z(q, temp.get_mpz_t());
+  expr.eval(mpq_numref(q));
+  mpz_set_ui(mpq_denref(q),1);
 }
 
 template <>
@@ -2208,7 +2208,7 @@
 public:
   __gmp_expr(const val_type &val) : expr(val) { }
   void eval(typename __gmp_resolve_expr<T>::ptr_type p) const
-  { __gmp_expr<T, T> temp(expr.val); Op::eval(p, temp.__get_mp()); }
+  { expr.val.eval(p); Op::eval(p, p); }
   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()); }


More information about the gmp-bugs mailing list