This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FYI: Patch: java.net.InetAddress


On Monday, Sep 29, 2003, at 23:55 Pacific/Auckland, Michael Koch wrote:

I commited the attached patch to trunk to merge the comments of some
methods with classpath and to simplify isMulticastAddress().

Index: java/net/InetAddress.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/InetAddress.java,v
retrieving revision 1.20
diff -u -b -B -r1.20 InetAddress.java
--- java/net/InetAddress.java	29 Sep 2003 11:24:28 -0000	1.20
+++ java/net/InetAddress.java	29 Sep 2003 11:39:32 -0000
@@ -140,12 +140,12 @@
    */
   public boolean isMulticastAddress()
   {
-    int len = addr.length;
-
-    if (len == 4)
+    // Mask against high order bits of 1110
+    if (addr.length == 4)
       return (addr [0] & 0xF0) == 0xE0;

Note that often, its is more efficient to copy a class field into a local variable if it is going to be used more than once. This prevents the field being reloaded in cases where the compiler can't guarantee that it wont have changed due to, say, a method call in between.


In this case, however, the compiler is hopefully smart enough to optimize out the second load, so it isn't a problem.


- if (len == 16) + // Mask against high order bits of 11111111 + if (addr.lenth == 16) return addr [0] == (byte) 0xFF;

^^ typo ?


Regards

Bryce



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]