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
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -99,14 +99,16 @@ public class Name extends TrackedStreamableObject
|
||||
// documentation inherited
|
||||
public boolean equals (Object other)
|
||||
{
|
||||
// we have to be of the same derived class but we don't want to
|
||||
// wig out if the classes were loaded from different class loaders
|
||||
if (other == null ||
|
||||
!other.getClass().getName().equals(getClass().getName())) {
|
||||
return false;
|
||||
} else {
|
||||
return getNormal().equals(((Name)other).getNormal());
|
||||
if (other != null) {
|
||||
Class c = getClass();
|
||||
Class oc = other.getClass();
|
||||
// we have to be of the same derived class but we don't want to
|
||||
// wig out if the classes were loaded from different class loaders
|
||||
if (c == oc || c.getName().equals(oc.getName())) {
|
||||
return getNormal().equals(((Name)other).getNormal());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
|
||||
Reference in New Issue
Block a user