Convert some more ctors from copying to moving STL containers.
authorRichard Kreckel <kreckel@ginac.de>
Mon, 23 Nov 2015 18:36:53 +0000 (19:36 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Mon, 23 Nov 2015 18:36:53 +0000 (19:36 +0100)
ginac/normal.cpp
ginac/power.cpp
ginac/pseries.cpp

index c6dc39e..e30afda 100644 (file)
@@ -1210,7 +1210,7 @@ ex add::smod(const numeric &xi) const
        }
        GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
        numeric coeff = GiNaC::smod(ex_to<numeric>(overall_coeff), xi);
-       return (new add(newseq,coeff))->setflag(status_flags::dynallocated);
+       return (new add(std::move(newseq), coeff))->setflag(status_flags::dynallocated);
 }
 
 ex mul::smod(const numeric &xi) const
index b12ff8a..bf48e93 100644 (file)
@@ -775,7 +775,7 @@ ex power::derivative(const symbol & s) const
                newseq.reserve(2);
                newseq.push_back(expair(basis, exponent - _ex1));
                newseq.push_back(expair(basis.diff(s), _ex1));
-               return mul(newseq, exponent);
+               return mul(std::move(newseq), exponent);
        } else {
                // D(b^e) = b^e * (D(e)*ln(b) + e*D(b)/b)
                return mul(*this,
@@ -849,9 +849,9 @@ ex power::expand(unsigned options) const
                // In either case we set a flag to avoid the second run on a part
                // which does not have positive/negative terms.
                if (prodseq.size() > 0) {
-                       ex newbasis = coeff*mul(powseq);
+                       ex newbasis = coeff*mul(std::move(powseq));
                        ex_to<basic>(newbasis).setflag(status_flags::purely_indefinite);
-                       return ((new mul(prodseq))->setflag(status_flags::dynallocated)*(new power(newbasis, exponent))->setflag(status_flags::dynallocated).expand(options)).expand(options);
+                       return ((new mul(std::move(prodseq)))->setflag(status_flags::dynallocated)*(new power(newbasis, exponent))->setflag(status_flags::dynallocated).expand(options)).expand(options);
                } else
                        ex_to<basic>(basis).setflag(status_flags::purely_indefinite);
        }
@@ -1237,11 +1237,11 @@ ex power::expand_add(const add & a, int n, unsigned options) const
        GINAC_ASSERT(result.size() == result_size);
 
        if (a.overall_coeff.is_zero()) {
-               return (new add(result))->setflag(status_flags::dynallocated |
-                                                 status_flags::expanded);
+               return (new add(std::move(result)))->setflag(status_flags::dynallocated |
+                                                            status_flags::expanded);
        } else {
-               return (new add(result, ex_to<numeric>(a.overall_coeff).power(n)))->setflag(status_flags::dynallocated |
-                                                                                           status_flags::expanded);
+               return (new add(std::move(result), ex_to<numeric>(a.overall_coeff).power(n)))->setflag(status_flags::dynallocated |
+                                                                                                      status_flags::expanded);
        }
 }
 
@@ -1309,7 +1309,7 @@ ex power::expand_add_2(const add & a, unsigned options) const
        
        GINAC_ASSERT(sum.size()==(a_nops*(a_nops+1))/2);
        
-       return (new add(sum))->setflag(status_flags::dynallocated | status_flags::expanded);
+       return (new add(std::move(sum)))->setflag(status_flags::dynallocated | status_flags::expanded);
 }
 
 /** Expand factors of m in m^n where m is a mul and n is an integer.
index 01b2691..12b57d6 100644 (file)
@@ -1219,7 +1219,7 @@ ex integral::series(const relational & r, int order, unsigned options) const
        }
 
        // Expanding lower boundary
-       ex result = (new pseries(r, fexpansion))->setflag(status_flags::dynallocated);
+       ex result = (new pseries(r, std::move(fexpansion)))->setflag(status_flags::dynallocated);
        ex aseries = (a-a.subs(r)).series(r, order, options);
        fseries = f.series(x == (a.subs(r)), order, options);
        for (size_t i=0; i<fseries.nops(); ++i) {