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;
}