* Some minor optimization glitches.
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Fri, 16 Nov 2001 18:59:12 +0000 (18:59 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Fri, 16 Nov 2001 18:59:12 +0000 (18:59 +0000)
ginac/add.cpp
ginac/expairseq.cpp
ginac/mul.cpp

index 1f71b06..b9eca99 100644 (file)
@@ -445,7 +445,7 @@ expair add::split_ex_to_pair(const ex & e) const
 {
        if (is_ex_exactly_of_type(e,mul)) {
                const mul &mulref(ex_to<mul>(e));
-               ex numfactor = mulref.overall_coeff;
+               const ex &numfactor = mulref.overall_coeff;
                mul *mulcopyp = new mul(mulref);
                mulcopyp->overall_coeff = _ex1;
                mulcopyp->clearflag(status_flags::evaluated);
@@ -462,7 +462,7 @@ expair add::combine_ex_with_coeff_to_pair(const ex & e,
        GINAC_ASSERT(is_exactly_a<numeric>(c));
        if (is_ex_exactly_of_type(e, mul)) {
                const mul &mulref(ex_to<mul>(e));
-               ex numfactor = mulref.overall_coeff;
+               const ex &numfactor = mulref.overall_coeff;
                mul *mulcopyp = new mul(mulref);
                mulcopyp->overall_coeff = _ex1;
                mulcopyp->clearflag(status_flags::evaluated);
@@ -501,7 +501,7 @@ ex add::recombine_pair_to_ex(const expair & p) const
        if (ex_to<numeric>(p.coeff).is_equal(_num1))
                return p.rest;
        else
-               return p.rest*p.coeff;
+               return (new mul(p.rest,p.coeff))->setflag(status_flags::dynallocated);
 }
 
 ex add::expand(unsigned options) const
index fee2665..08c81d0 100644 (file)
@@ -1466,7 +1466,7 @@ bool expairseq::is_canonical() const
  *  if no members were changed. */
 epvector * expairseq::expandchildren(unsigned options) const
 {
-       epvector::const_iterator last = seq.end();
+       const epvector::const_iterator last = seq.end();
        epvector::const_iterator cit = seq.begin();
        while (cit!=last) {
                const ex &expanded_ex = cit->rest.expand(options);
index 065455e..64b090a 100644 (file)
@@ -745,7 +745,7 @@ ex mul::expand(unsigned options) const
  *  pointer, if sequence is unchanged. */
 epvector * mul::expandchildren(unsigned options) const
 {
-       epvector::const_iterator last = seq.end();
+       const epvector::const_iterator last = seq.end();
        epvector::const_iterator cit = seq.begin();
        while (cit!=last) {
                const ex & factor = recombine_pair_to_ex(*cit);