You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2016/06/02 11:02:12 UTC

[lang] LANG-1243 Simplify ArrayUtils removeElements by using new decrementAndGet() method

Repository: commons-lang
Updated Branches:
  refs/heads/master e47426366 -> 844b2901f


LANG-1243 Simplify ArrayUtils removeElements by using new
decrementAndGet() method

Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/844b2901
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/844b2901
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/844b2901

Branch: refs/heads/master
Commit: 844b2901fe4049fba29ce8c6961dfa25966974ef
Parents: e474263
Author: Sebb <se...@apache.org>
Authored: Thu Jun 2 12:02:08 2016 +0100
Committer: Sebb <se...@apache.org>
Committed: Thu Jun 2 12:02:08 2016 +0100

----------------------------------------------------------------------
 src/changes/changes.xml                         |  1 +
 .../org/apache/commons/lang3/ArrayUtils.java    | 27 +++++++-------------
 2 files changed, 10 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/844b2901/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c35e734..3de84a2 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
 
   <release version="3.5" date="tba" description="tba">
+    <action issue="LANG-1243" type="update" dev="sebb">Simplify ArrayUtils removeElements by using new decrementAndGet() method</action>
     <action issue="LANG-1189" type="add" dev="sebb" due-to="haiyang li / Matthew Bartenschlag ">Add getAndIncrement/getAndDecrement/getAndAdd/incrementAndGet/decrementAndGet/addAndGet in Mutable* classes</action>
     <action issue="LANG-1240" type="update" dev="pschumacher" due-to="zhanhb">Optimize BitField constructor implementation</action>
     <action issue="LANG-1206" type="update" dev="pschumacher" due-to="Mohammed Alfallaj">Improve CharSetUtils.squeeze() performance</action>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/844b2901/src/main/java/org/apache/commons/lang3/ArrayUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
index 0d6a02a..1105725 100644
--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java
@@ -6585,8 +6585,7 @@ public class ArrayUtils {
             final T key = array[i];
             final MutableInt count = occurrences.get(key);
             if (count != null) {
-                count.decrement();
-                if (count.intValue() == 0) {
+                if (count.decrementAndGet() == 0) {
                     occurrences.remove(key);
                 }
                 toRemove.set(i);
@@ -6677,8 +6676,7 @@ public class ArrayUtils {
             final byte key = array[i];
             final MutableInt count = occurrences.get(key);
             if (count != null) {
-                count.decrement();
-                if (count.intValue() == 0) {
+                if (count.decrementAndGet() == 0) {
                     occurrences.remove(key);
                 }
                 toRemove.set(i);
@@ -6766,8 +6764,7 @@ public class ArrayUtils {
             final short key = array[i];
             final MutableInt count = occurrences.get(key);
             if (count != null) {
-                count.decrement();
-                if (count.intValue() == 0) {
+                if (count.decrementAndGet() == 0) {
                     occurrences.remove(key);
                 }
                 toRemove.set(i);
@@ -6855,8 +6852,7 @@ public class ArrayUtils {
             final int key = array[i];
             final MutableInt count = occurrences.get(key);
             if (count != null) {
-                count.decrement();
-                if (count.intValue() == 0) {
+                if (count.decrementAndGet() == 0) {
                     occurrences.remove(key);
                 }
                 toRemove.set(i);
@@ -6944,8 +6940,7 @@ public class ArrayUtils {
             final char key = array[i];
             final MutableInt count = occurrences.get(key);
             if (count != null) {
-                count.decrement();
-                if (count.intValue() == 0) {
+                if (count.decrementAndGet() == 0) {
                     occurrences.remove(key);
                 }
                 toRemove.set(i);
@@ -7033,8 +7028,7 @@ public class ArrayUtils {
             final long key = array[i];
             final MutableInt count = occurrences.get(key);
             if (count != null) {
-                count.decrement();
-                if (count.intValue() == 0) {
+                if (count.decrementAndGet() == 0) {
                     occurrences.remove(key);
                 }
                 toRemove.set(i);
@@ -7122,8 +7116,7 @@ public class ArrayUtils {
             final float key = array[i];
             final MutableInt count = occurrences.get(key);
             if (count != null) {
-                count.decrement();
-                if (count.intValue() == 0) {
+                if (count.decrementAndGet() == 0) {
                     occurrences.remove(key);
                 }
                 toRemove.set(i);
@@ -7211,8 +7204,7 @@ public class ArrayUtils {
             final double key = array[i];
             final MutableInt count = occurrences.get(key);
             if (count != null) {
-                count.decrement();
-                if (count.intValue() == 0) {
+                if (count.decrementAndGet() == 0) {
                     occurrences.remove(key);
                 }
                 toRemove.set(i);
@@ -7296,8 +7288,7 @@ public class ArrayUtils {
             final boolean key = array[i];
             final MutableInt count = occurrences.get(key);
             if (count != null) {
-                count.decrement();
-                if (count.intValue() == 0) {
+                if (count.decrementAndGet() == 0) {
                     occurrences.remove(key);
                 }
                 toRemove.set(i);