Goodness, let's optimizee the common case: if two name objects ARE the
same class and loaded from the same class loader we don't need to do two string compares. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3678 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Name.java,v 1.4 2004/08/27 02:20:36 mdb Exp $
|
// $Id$
|
||||||
//
|
//
|
||||||
// Narya library - tools for developing networked games
|
// Narya library - tools for developing networked games
|
||||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||||
@@ -99,14 +99,16 @@ public class Name extends TrackedStreamableObject
|
|||||||
// documentation inherited
|
// documentation inherited
|
||||||
public boolean equals (Object other)
|
public boolean equals (Object other)
|
||||||
{
|
{
|
||||||
// we have to be of the same derived class but we don't want to
|
if (other != null) {
|
||||||
// wig out if the classes were loaded from different class loaders
|
Class c = getClass();
|
||||||
if (other == null ||
|
Class oc = other.getClass();
|
||||||
!other.getClass().getName().equals(getClass().getName())) {
|
// we have to be of the same derived class but we don't want to
|
||||||
return false;
|
// wig out if the classes were loaded from different class loaders
|
||||||
} else {
|
if (c == oc || c.getName().equals(oc.getName())) {
|
||||||
return getNormal().equals(((Name)other).getNormal());
|
return getNormal().equals(((Name)other).getNormal());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
|
|||||||
Reference in New Issue
Block a user