diff --git a/src/helma/objectmodel/db/DbKey.java b/src/helma/objectmodel/db/DbKey.java index ff8b5041..436445fc 100644 --- a/src/helma/objectmodel/db/DbKey.java +++ b/src/helma/objectmodel/db/DbKey.java @@ -37,13 +37,12 @@ public final class DbKey implements Key, Serializable { public boolean equals (Object what) { if (what == this) return true; - try { - DbKey k = (DbKey) what; - return (storageName == k.storageName || storageName.equals (k.storageName)) && - (id == k.id || id.equals (k.id)); - } catch (Exception x) { + if (!(what instanceof DbKey)) return false; - } + DbKey k = (DbKey) what; + // storageName is an interned string (by DbMapping, from where we got it) + // so we can compare by using == instead of the equals method. + return storageName == k.storageName && (id == k.id || id.equals (k.id)); } public int hashCode () { diff --git a/src/helma/objectmodel/db/SyntheticKey.java b/src/helma/objectmodel/db/SyntheticKey.java index 7f1911ac..edb9b114 100644 --- a/src/helma/objectmodel/db/SyntheticKey.java +++ b/src/helma/objectmodel/db/SyntheticKey.java @@ -32,13 +32,11 @@ public final class SyntheticKey implements Key, Serializable { public boolean equals (Object what) { if (what == this) return true; - try { - SyntheticKey k = (SyntheticKey) what; - return parentKey.equals (k.parentKey) && - (name == k.name || name.equals (k.name)); - } catch (Exception x) { + if (!(what instanceof SyntheticKey)) return false; - } + SyntheticKey k = (SyntheticKey) what; + return parentKey.equals (k.parentKey) && + (name == k.name || name.equals (k.name)); } public int hashCode () {