This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: SocketPermission fixlet
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 04 Dec 2002 19:10:03 -0700
- Subject: Patch: FYI: SocketPermission fixlet
- Reply-to: tromey at redhat dot com
I'm checking this in.
This changes SocketPermission.hashCode to be more efficient, more
correct, and to take all its fields into account.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/net/SocketPermission.java (hashCode): Rewrote.
Index: java/net/SocketPermission.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/SocketPermission.java,v
retrieving revision 1.8
diff -u -r1.8 SocketPermission.java
--- java/net/SocketPermission.java 7 Nov 2002 09:40:00 -0000 1.8
+++ java/net/SocketPermission.java 5 Dec 2002 01:58:42 -0000
@@ -1,5 +1,5 @@
/* SocketPermission.java -- Class modeling permissions for socket operations
- Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -166,12 +166,11 @@
public int hashCode()
{
int hash = 100;
-
- // FIXME: Get a real hash function
- for (int i = 0; i < hostport.length(); i++)
- hash = hash + (int) hostport.charAt(i) * 7;
-
- return (hash);
+ if (hostport != null)
+ hash += hostport.hashCode();
+ if (actions != null)
+ hash += actions.hashCode();
+ return hash;
}
/**