[Swift-commit] r5783 - trunk/src/org/griphyn/vdl/util
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Mon Apr 30 22:54:00 CDT 2012
Author: hategan
Date: 2012-04-30 22:53:59 -0500 (Mon, 30 Apr 2012)
New Revision: 5783
Modified:
trunk/src/org/griphyn/vdl/util/FQN.java
Log:
cache FQN hash code
Modified: trunk/src/org/griphyn/vdl/util/FQN.java
===================================================================
--- trunk/src/org/griphyn/vdl/util/FQN.java 2012-05-01 03:52:06 UTC (rev 5782)
+++ trunk/src/org/griphyn/vdl/util/FQN.java 2012-05-01 03:53:59 UTC (rev 5783)
@@ -31,11 +31,13 @@
private final String namespace;
private final String name;
private final String version;
+ private final int hashCode;
public FQN(String namespace, String name, String version) {
this.namespace = namespace;
this.name = name;
this.version = version;
+ this.hashCode = _hashCode();
}
public FQN(String fqn) {
@@ -72,6 +74,7 @@
else {
throw new IllegalArgumentException("Invalid FQN: " + fqn);
}
+ this.hashCode = _hashCode();
}
private String[] split(String fqn) {
@@ -117,6 +120,9 @@
public boolean equals(Object o) {
if (o instanceof FQN) {
FQN of = (FQN) o;
+ if (hashCode != of.hashCode) {
+ return false;
+ }
return cmpStr(namespace, of.namespace) && cmpStr(name, of.name)
&& cmpStr(version, of.version);
}
@@ -125,13 +131,17 @@
}
}
- public int hashCode() {
+ private int _hashCode() {
int hc = 0;
hc += namespace == null ? 0 : namespace.hashCode();
hc += name == null ? 0 : name.hashCode();
hc += version == null ? 0 : version.hashCode();
return hc;
}
+
+ public int hashCode() {
+ return hashCode;
+ }
private boolean cmpStr(String s1, String s2) {
if (s1 == null) {
More information about the Swift-commit
mailing list