You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ij...@apache.org on 2020/05/26 04:52:09 UTC

[kafka] branch trunk updated: MINOR: avoid unnecessary list iteration in ApiVersion.lastVersion (#8708)

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

ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new c6adcca  MINOR: avoid unnecessary list iteration in ApiVersion.lastVersion (#8708)
c6adcca is described below

commit c6adcca95f03758089715c60e806a8090f5422d9
Author: Lucas Bradstreet <lu...@confluent.io>
AuthorDate: Mon May 25 21:51:14 2020 -0700

    MINOR: avoid unnecessary list iteration in ApiVersion.lastVersion (#8708)
    
    We unnecessarily iterate the versions list each time we lookup
    lastVersion, including in the hotpath Log.appendAsFollower.
    Given that allVersions is a constant, this is unnecessary.
    
    Reviewers: Chia-Ping Tsai <ch...@gmail.com>, Ismael Juma <is...@juma.me.uk>
---
 core/src/main/scala/kafka/api/ApiVersion.scala | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/src/main/scala/kafka/api/ApiVersion.scala b/core/src/main/scala/kafka/api/ApiVersion.scala
index 21e01e8..c723f7b 100644
--- a/core/src/main/scala/kafka/api/ApiVersion.scala
+++ b/core/src/main/scala/kafka/api/ApiVersion.scala
@@ -116,7 +116,7 @@ object ApiVersion {
     versionMap.getOrElse(key, throw new IllegalArgumentException(s"Version `$versionString` is not a valid version"))
   }
 
-  def latestVersion: ApiVersion = allVersions.last
+  val latestVersion: ApiVersion = allVersions.last
 
   /**
    * Return the minimum `ApiVersion` that supports `RecordVersion`.