]> www.ginac.de Git - ginac.git/commitdiff
* 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 1f71b0606d7ff9b9ed9f9c943e075412a7e945d4..b9eca995affd6d9cc295118062f67d79d74f89e2 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));
 {
        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);
                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));
        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);
                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
        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
 }
 
 ex add::expand(unsigned options) const
index fee2665c322600e58529bf828e5ed0337e0a2e78..08c81d0313baab96eb83496e473f26fcadeb5160 100644 (file)
@@ -1466,7 +1466,7 @@ bool expairseq::is_canonical() const
  *  if no members were changed. */
 epvector * expairseq::expandchildren(unsigned options) 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);
        epvector::const_iterator cit = seq.begin();
        while (cit!=last) {
                const ex &expanded_ex = cit->rest.expand(options);
index 065455eabb62c08b8b0affc9f7e45b24515331e4..64b090af6ecdd1f721e69617b022625c1ef5df26 100644 (file)
@@ -745,7 +745,7 @@ ex mul::expand(unsigned options) const
  *  pointer, if sequence is unchanged. */
 epvector * mul::expandchildren(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);
        epvector::const_iterator cit = seq.begin();
        while (cit!=last) {
                const ex & factor = recombine_pair_to_ex(*cit);