summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorGravatar Dan Liew <daniel.liew@imperial.ac.uk>2015-02-02 16:00:34 +0000
committerGravatar Dan Liew <daniel.liew@imperial.ac.uk>2015-02-02 16:00:34 +0000
commita7843fac5cfc4b5d755a10fc61dce896cc881d9e (patch)
tree7c5c6b9776cdab8b17bb20d29b8584bd74d0e471 /Source/Core
parent964ee79dcfd492afd6c4a7c21b67089b76cd78e0 (diff)
Fix performance issue in ComputeHashCode() methods of Expr classes.
If constructing immutable Expr bottom up this would be very inefficient because the hashcode would be recomputed unnecessarily. Now just make ComputeHashCode() methods call GetHashCode() on Expr instead.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/AbsyExpr.cs10
-rw-r--r--Source/Core/AbsyQuant.cs2
2 files changed, 6 insertions, 6 deletions
diff --git a/Source/Core/AbsyExpr.cs b/Source/Core/AbsyExpr.cs
index 3c3c8e42..4efabe97 100644
--- a/Source/Core/AbsyExpr.cs
+++ b/Source/Core/AbsyExpr.cs
@@ -60,7 +60,7 @@ namespace Microsoft.Boogie {
/// Computes the hash code of this Expr skipping any cache.
///
/// Sub classes should place their implementation of computing their hashcode
- /// here (making sure to call ComputeHashCode() and not GetHashCode() on Expr)
+ /// here (making sure to call GetHashCode() not ComputeHashCode() on Expr for performance reasons)
/// and have GetHashCode() use a cached result from ComputeHashCode() if the
/// Expr was constructed to be immutable.
/// </summary>
@@ -992,7 +992,7 @@ namespace Microsoft.Boogie {
}
public override int ComputeHashCode() {
// FIXME: This is wrong, it's as if the OldExpr node isn't there at all
- return this.Expr == null ? 0 : this.Expr.ComputeHashCode();
+ return this.Expr == null ? 0 : this.Expr.GetHashCode();
}
public override void Emit(TokenTextWriter stream, int contextBindingStrength, bool fragileContext) {
@@ -2316,7 +2316,7 @@ namespace Microsoft.Boogie {
// DO NOT USE Args.GetHashCode() because that uses Object.GetHashCode() which uses references
// We want structural equality
foreach (var arg in Args) {
- h = (97*h) + arg.ComputeHashCode();
+ h = (97*h) + arg.GetHashCode();
}
return h;
}
@@ -2981,7 +2981,7 @@ namespace Microsoft.Boogie {
[Pure]
public override int ComputeHashCode() {
- int h = this.Bitvector.ComputeHashCode();
+ int h = this.Bitvector.GetHashCode();
h ^= Start * 17 ^ End * 13;
return h;
}
@@ -3092,7 +3092,7 @@ namespace Microsoft.Boogie {
[Pure]
public override int ComputeHashCode() {
- int h = this.E0.ComputeHashCode() ^ this.E1.ComputeHashCode() * 17;
+ int h = this.E0.GetHashCode() ^ this.E1.GetHashCode() * 17;
return h;
}
diff --git a/Source/Core/AbsyQuant.cs b/Source/Core/AbsyQuant.cs
index 1bd16e4a..2258e553 100644
--- a/Source/Core/AbsyQuant.cs
+++ b/Source/Core/AbsyQuant.cs
@@ -143,7 +143,7 @@ namespace Microsoft.Boogie {
h = ( 53 * h ) + dummyVar.GetHashCode();
}
- h ^= this.Body.ComputeHashCode();
+ h ^= this.Body.GetHashCode();
// DO NOT USE TypeParameters.GetHashCode() because we want structural
// identical Expr to have the same hash code **not** identical references