You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2013/10/26 19:11:26 UTC

svn commit: r1536008 - /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/Var.java

Author: andy
Date: Sat Oct 26 17:11:26 2013
New Revision: 1536008

URL: http://svn.apache.org/r1536008
Log:
Calculate and cache hashCode early because it tends to be heavily used in query execution.

Modified:
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/Var.java

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/Var.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/Var.java?rev=1536008&r1=1536007&r2=1536008&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/Var.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/Var.java Sat Oct 26 17:11:26 2013
@@ -87,7 +87,10 @@ public class Var extends Node_Variable
         return var ;
     }
     
-    private Var(String varName)      { super(varName) ; }
+    // Precalulated the hash code because hashCode() is used so heavily with Var's
+    private final int hashCodeValue ;  
+    
+    private Var(String varName)      { super(varName) ; hashCodeValue = super.hashCode() ; }
     
     private Var(Node_Variable v)     { this( v.getName() ) ; }
     
@@ -102,12 +105,12 @@ public class Var extends Node_Variable
     {
         NotAVariableException(String msg) { super(msg) ; }
     }
-
+    
     @Override
-    public int hashCode() { return super.hashCode() ; }
+    public final int hashCode() { return hashCodeValue ; }
 
     @Override
-    public boolean equals(Object other)
+    public final boolean equals(Object other)
     { 
         if ( this == other ) return true ;
         if ( ! ( other instanceof Var ) ) return false ;