You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by aa...@apache.org on 2019/10/23 10:38:44 UTC

[pulsar] branch master updated: Replace foreach with System.arraycopy (#5424)

This is an automated email from the ASF dual-hosted git repository.

aahmed pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new e73fc00  Replace foreach with System.arraycopy (#5424)
e73fc00 is described below

commit e73fc0007bd60cfa21accb819abacd4b3ebccd40
Author: Like <ke...@outlook.com>
AuthorDate: Wed Oct 23 18:38:36 2019 +0800

    Replace foreach with System.arraycopy (#5424)
---
 .../main/java/org/apache/pulsar/broker/stats/NamespaceStats.java  | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/NamespaceStats.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/NamespaceStats.java
index e5c8735..6b7ce93 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/NamespaceStats.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/NamespaceStats.java
@@ -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;
@@ -107,16 +108,13 @@ public class NamespaceStats {
 
     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);
         }
     }