This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: removing redundant checks
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 11 Nov 2003 13:27:01 +0100
- Subject: FYI: Patch: removing redundant checks
Hi list,
I commited the attached patch to remove some redundant obj == null checks all
over.
Michael
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2329
diff -u -b -B -r1.2329 ChangeLog
--- ChangeLog 11 Nov 2003 11:56:57 -0000 1.2329
+++ ChangeLog 11 Nov 2003 12:20:59 -0000
@@ -1,5 +1,20 @@
2003-11-11 Michael Koch <konqueror@gmx.de>
+ * java/awt/Font.java,
+ java/awt/datatransfer/DataFlavor.java,
+ java/math/BigInteger.java,
+ java/net/Inet4Address.java,
+ java/net/Inet6Address.java,
+ java/rmi/MarshalledObject.java,
+ java/rmi/server/RMIClassLoader.java,
+ java/security/cert/CertStore.java,
+ java/sql/Timestamp.java,
+ java/text/SimpleDateFormat.java,
+ javax/naming/CompoundName.java:
+ Removed some redundant obj == null checks.
+
+2003-11-11 Michael Koch <konqueror@gmx.de>
+
* java/nio/ByteBuffer.java
(equals): Remove redundant obj == null check.
Index: java/awt/Font.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Font.java,v
retrieving revision 1.14
diff -u -b -B -r1.14 Font.java
--- java/awt/Font.java 13 Aug 2003 16:49:57 -0000 1.14
+++ java/awt/Font.java 11 Nov 2003 12:21:00 -0000
@@ -1226,9 +1226,6 @@
public boolean
equals(Object obj)
{
- if (obj == null)
- return(false);
-
if (!(obj instanceof Font))
return(false);
Index: java/awt/datatransfer/DataFlavor.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/datatransfer/DataFlavor.java,v
retrieving revision 1.10
diff -u -b -B -r1.10 DataFlavor.java
--- java/awt/datatransfer/DataFlavor.java 5 Jun 2003 19:58:40 -0000 1.10
+++ java/awt/datatransfer/DataFlavor.java 11 Nov 2003 12:21:01 -0000
@@ -723,9 +723,6 @@
public boolean
equals(Object obj)
{
- if (obj == null)
- return(false);
-
if (!(obj instanceof DataFlavor))
return(false);
Index: java/math/BigInteger.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/math/BigInteger.java,v
retrieving revision 1.24
diff -u -b -B -r1.24 BigInteger.java
--- java/math/BigInteger.java 9 Oct 2003 13:13:05 -0000 1.24
+++ java/math/BigInteger.java 11 Nov 2003 12:21:02 -0000
@@ -1565,7 +1565,7 @@
/* Assumes this and obj are both canonicalized. */
public boolean equals(Object obj)
{
- if (obj == null || ! (obj instanceof BigInteger))
+ if (! (obj instanceof BigInteger))
return false;
return equals(this, (BigInteger) obj);
}
Index: java/net/Inet4Address.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Inet4Address.java,v
retrieving revision 1.6
diff -u -b -B -r1.6 Inet4Address.java
--- java/net/Inet4Address.java 9 Nov 2003 23:07:11 -0000 1.6
+++ java/net/Inet4Address.java 11 Nov 2003 12:21:02 -0000
@@ -258,7 +258,7 @@
*/
public boolean equals (Object obj)
{
- if (obj == null || ! (obj instanceof InetAddress))
+ if (! (obj instanceof InetAddress))
return false;
byte[] addr1 = addr;
Index: java/net/Inet6Address.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Inet6Address.java,v
retrieving revision 1.5
diff -u -b -B -r1.5 Inet6Address.java
--- java/net/Inet6Address.java 27 Jun 2003 15:48:15 -0000 1.5
+++ java/net/Inet6Address.java 11 Nov 2003 12:21:02 -0000
@@ -243,7 +243,7 @@
*/
public boolean equals (Object obj)
{
- if (obj == null || ! (obj instanceof Inet6Address))
+ if (! (obj instanceof Inet6Address))
return false;
Inet6Address tmp = (Inet6Address) obj;
Index: java/rmi/MarshalledObject.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/rmi/MarshalledObject.java,v
retrieving revision 1.4
diff -u -b -B -r1.4 MarshalledObject.java
--- java/rmi/MarshalledObject.java 7 Nov 2002 18:01:03 -0000 1.4
+++ java/rmi/MarshalledObject.java 11 Nov 2003 12:21:02 -0000
@@ -76,7 +76,7 @@
public boolean equals(Object obj)
{
- if(obj == null || !(obj instanceof MarshalledObject) )
+ if (! (obj instanceof MarshalledObject))
return false;
// hashCode even differs, don't do the time-consuming comparisons
Index: java/rmi/server/RMIClassLoader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/rmi/server/RMIClassLoader.java,v
retrieving revision 1.9
diff -u -b -B -r1.9 RMIClassLoader.java
--- java/rmi/server/RMIClassLoader.java 11 Oct 2003 18:30:22 -0000 1.9
+++ java/rmi/server/RMIClassLoader.java 11 Nov 2003 12:21:02 -0000
@@ -113,8 +113,7 @@
*/
public boolean equals (Object theOther)
{
- if (theOther != null
- && theOther instanceof CacheKey)
+ if (theOther instanceof CacheKey)
{
CacheKey key = (CacheKey) theOther;
Index: java/security/cert/CertStore.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/security/cert/CertStore.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 CertStore.java
--- java/security/cert/CertStore.java 30 Apr 2003 07:23:42 -0000 1.1
+++ java/security/cert/CertStore.java 11 Nov 2003 12:21:02 -0000
@@ -215,8 +215,7 @@
catch (java.lang.reflect.InvocationTargetException ite)
{
Throwable cause = ite.getCause();
- if (cause != null &&
- (cause instanceof InvalidAlgorithmParameterException))
+ if (cause instanceof InvalidAlgorithmParameterException)
throw (InvalidAlgorithmParameterException) cause;
else
throw new NoSuchAlgorithmException(type);
Index: java/sql/Timestamp.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/sql/Timestamp.java,v
retrieving revision 1.8
diff -u -b -B -r1.8 Timestamp.java
--- java/sql/Timestamp.java 11 Nov 2003 00:51:44 -0000 1.8
+++ java/sql/Timestamp.java 11 Nov 2003 12:21:03 -0000
@@ -224,9 +224,6 @@
*/
public boolean equals(Object obj)
{
- if (obj == null)
- return false;
-
if (!(obj instanceof Timestamp))
return false;
Index: java/text/SimpleDateFormat.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/SimpleDateFormat.java,v
retrieving revision 1.23
diff -u -b -B -r1.23 SimpleDateFormat.java
--- java/text/SimpleDateFormat.java 8 Oct 2003 20:48:11 -0000 1.23
+++ java/text/SimpleDateFormat.java 11 Nov 2003 12:21:03 -0000
@@ -374,9 +374,6 @@
*/
public boolean equals(Object o)
{
- if (o == null)
- return false;
-
if (!super.equals(o))
return false;
Index: javax/naming/CompoundName.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/naming/CompoundName.java,v
retrieving revision 1.4
diff -u -b -B -r1.4 CompoundName.java
--- javax/naming/CompoundName.java 14 Jul 2003 05:33:30 -0000 1.4
+++ javax/naming/CompoundName.java 11 Nov 2003 12:21:03 -0000
@@ -240,7 +240,7 @@
public int compareTo (Object obj)
{
- if (obj == null || ! (obj instanceof CompoundName))
+ if (! (obj instanceof CompoundName))
throw new ClassCastException ("CompoundName.compareTo() expected CompoundName");
CompoundName cn = (CompoundName) obj;
int last = Math.min (cn.elts.size (), elts.size ());