You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/12/28 21:21:01 UTC
[commons-collections] branch master updated: Use Arrays.copyOf()
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git
The following commit(s) were added to refs/heads/master by this push:
new 1fb9183c7 Use Arrays.copyOf()
1fb9183c7 is described below
commit 1fb9183c706a8d660b856e9d8e66525525327418
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 28 16:20:57 2022 -0500
Use Arrays.copyOf()
---
src/main/java/org/apache/commons/collections4/map/CompositeMap.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/commons/collections4/map/CompositeMap.java b/src/main/java/org/apache/commons/collections4/map/CompositeMap.java
index 2f893979d..a5c0c44cf 100644
--- a/src/main/java/org/apache/commons/collections4/map/CompositeMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/CompositeMap.java
@@ -17,6 +17,7 @@
package org.apache.commons.collections4.map;
import java.io.Serializable;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
@@ -132,7 +133,6 @@ public class CompositeMap<K, V> extends AbstractIterableMap<K, V> implements Ser
* @throws IllegalArgumentException if there is a key collision and there is no
* MapMutator set to handle it.
*/
- @SuppressWarnings("unchecked")
public synchronized void addComposited(final Map<K, V> map) throws IllegalArgumentException {
if (map != null) {
for (int i = composite.length - 1; i >= 0; --i) {
@@ -144,8 +144,7 @@ public class CompositeMap<K, V> extends AbstractIterableMap<K, V> implements Ser
this.mutator.resolveCollision(this, this.composite[i], map, intersect);
}
}
- final Map<K, V>[] temp = new Map[this.composite.length + 1];
- System.arraycopy(this.composite, 0, temp, 0, this.composite.length);
+ final Map<K, V>[] temp = Arrays.copyOf(this.composite, this.composite.length + 1);
temp[temp.length - 1] = map;
this.composite = temp;
}