changeset 26451:f86e59f18322

8056951: pico-optimize contains(Object) methods Summary: use idiiom >= 0 consistently to check for valid index Reviewed-by: mduigou
author martin
date Fri, 29 Aug 2014 14:50:15 -0700
parents 7d90b73e92d4
children 04bfc550f2b4
files jdk/src/java.base/share/classes/java/lang/String.java jdk/src/java.base/share/classes/java/util/Arrays.java jdk/src/java.base/share/classes/java/util/LinkedList.java jdk/src/java.base/share/classes/java/util/PriorityQueue.java
diffstat 4 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/java/lang/String.java	Fri Sep 05 15:09:05 2014 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/String.java	Fri Aug 29 14:50:15 2014 -0700
@@ -2119,7 +2119,7 @@
      * @since 1.5
      */
     public boolean contains(CharSequence s) {
-        return indexOf(s.toString()) > -1;
+        return indexOf(s.toString()) >= 0;
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/util/Arrays.java	Fri Sep 05 15:09:05 2014 +0200
+++ b/jdk/src/java.base/share/classes/java/util/Arrays.java	Fri Aug 29 14:50:15 2014 -0700
@@ -3865,7 +3865,7 @@
 
         @Override
         public boolean contains(Object o) {
-            return indexOf(o) != -1;
+            return indexOf(o) >= 0;
         }
 
         @Override
--- a/jdk/src/java.base/share/classes/java/util/LinkedList.java	Fri Sep 05 15:09:05 2014 +0200
+++ b/jdk/src/java.base/share/classes/java/util/LinkedList.java	Fri Aug 29 14:50:15 2014 -0700
@@ -314,7 +314,7 @@
      * @return {@code true} if this list contains the specified element
      */
     public boolean contains(Object o) {
-        return indexOf(o) != -1;
+        return indexOf(o) >= 0;
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/util/PriorityQueue.java	Fri Sep 05 15:09:05 2014 +0200
+++ b/jdk/src/java.base/share/classes/java/util/PriorityQueue.java	Fri Aug 29 14:50:15 2014 -0700
@@ -406,7 +406,7 @@
      * @return {@code true} if this queue contains the specified element
      */
     public boolean contains(Object o) {
-        return indexOf(o) != -1;
+        return indexOf(o) >= 0;
     }
 
     /**