Skip to content

Commit

Permalink
Replace foreach with System.arraycopy (apache#5424)
Browse files Browse the repository at this point in the history
  • Loading branch information
liketic authored and aahmed-se committed Oct 23, 2019
1 parent 84a519f commit e73fc00
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.pulsar.broker.stats;

import java.util.Arrays;
import java.util.Map;

import static org.apache.bookkeeper.mledger.impl.ManagedLedgerMBeanImpl.ENTRY_LATENCY_BUCKETS_USEC;
Expand Down Expand Up @@ -107,16 +108,13 @@ public Metrics add(String namespace) {

public static void copy(long[] src, long[] dest) {
if (src != null && dest != null && src.length == dest.length) {
for (int i = 0; i < src.length; i++) {
dest[i] = src[i];
}
System.arraycopy(src, 0, dest, 0, src.length);
}
}

public static void clear(long[] list) {
if (list != null) {
for (int i = 0; i < list.length; i++)
list[i] = 0;
Arrays.fill(list, 0);
}
}

Expand Down

0 comments on commit e73fc00

Please sign in to comment.