X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fex.h;h=14695fd9b1b10258a0d25cc1f8d864211f6db50b;hp=95115a30fbbc6b35375329ca9c5989418d11808b;hb=3cfb99b28134e1acf8bad3fb672ff152dfd58601;hpb=f9c4dea564ba4a08f9e4f91cdd47223a735a5fe7;ds=sidebyside diff --git a/ginac/ex.h b/ginac/ex.h index 95115a30..14695fd9 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -358,24 +358,47 @@ ex::ex(const std::string &s, const ex &l) : bp(construct_from_string_and_lst(s, inline int ex::compare(const ex & other) const { +#ifdef GINAC_COMPARE_STATISTICS + compare_statistics.total_compares++; +#endif if (bp == other.bp) // trivial case: both expressions point to same basic return 0; +#ifdef GINAC_COMPARE_STATISTICS + compare_statistics.nontrivial_compares++; +#endif const int cmpval = bp->compare(*other.bp); +#if 1 if (cmpval == 0) { // Expressions point to different, but equal, trees: conserve // memory and make subsequent compare() operations faster by - // making both expression point to the same tree. + // making both expressions point to the same tree. share(other); } +#endif return cmpval; } inline bool ex::is_equal(const ex & other) const { +#ifdef GINAC_COMPARE_STATISTICS + compare_statistics.total_is_equals++; +#endif if (bp == other.bp) // trivial case: both expressions point to same basic return true; - return bp->is_equal(*other.bp); +#ifdef GINAC_COMPARE_STATISTICS + compare_statistics.nontrivial_is_equals++; +#endif + const bool equal = bp->is_equal(*other.bp); +#if 0 + if (equal) { + // Expressions point to different, but equal, trees: conserve + // memory and make subsequent compare() operations faster by + // making both expressions point to the same tree. + share(other); + } +#endif + return equal; }