You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2021/12/09 12:07:42 UTC

[pulsar] 02/02: [Perf] Evaluate the current protocol version once (#13045)

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

lhotari pushed a commit to branch branch-2.8
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 8fc36677fe3eb2344e6c42467ee393e4bab149fa
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Tue Nov 30 15:10:39 2021 +0200

    [Perf] Evaluate the current protocol version once (#13045)
    
    - there's no need to dynamically evaluate it on every call
    
    (cherry picked from commit 724523f3051def9577d6bd27697866c99f4a7b0e)
---
 .../src/main/java/org/apache/pulsar/common/protocol/Commands.java  | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java b/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
index 241ae87..01a7b01 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
@@ -124,6 +124,10 @@ public class Commands {
         }
     };
 
+    // Return the last ProtocolVersion enum value
+    private static final int CURRENT_PROTOCOL_VERSION =
+            ProtocolVersion.values()[ProtocolVersion.values().length - 1].getValue();
+
     private static BaseCommand localCmd(BaseCommand.Type type) {
         return LOCAL_BASE_COMMAND.get()
                 .clear()
@@ -1705,8 +1709,7 @@ public class Commands {
     }
 
     public static int getCurrentProtocolVersion() {
-        // Return the last ProtocolVersion enum value
-        return ProtocolVersion.values()[ProtocolVersion.values().length - 1].getValue();
+        return CURRENT_PROTOCOL_VERSION;
     }
 
     /**