From: Richard Kreckel Date: Thu, 1 Mar 2001 19:54:50 +0000 (+0000) Subject: * ginac/pseries.cpp (pseries::compare_same_type): optimized. X-Git-Tag: release_0-8-0~37 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=7db2d551ae2e9e4e7c5029eba73e90b420445ecc * ginac/pseries.cpp (pseries::compare_same_type): optimized. --- diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index fbb7583b..692efbcd 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -203,24 +203,31 @@ int pseries::compare_same_type(const basic & other) const { GINAC_ASSERT(is_of_type(other, pseries)); const pseries &o = static_cast(other); - + + // first compare the lengths of the series... + if (seq.size()>o.seq.size()) + return 1; + if (seq.size()compare(*it2); + + // ...and if that failed the individual elements + epvector::const_iterator it = seq.begin(), o_it = o.seq.begin(); + while (it!=seq.end() && o_it!=o.seq.end()) { + cmpval = it->compare(*o_it); if (cmpval) return cmpval; - it1++; it2++; + ++it; + ++o_it; } - if (it1 == it1end) - return it2 == it2end ? 0 : -1; - + // so they are equal. return 0; }