divijvaidya commented on code in PR #13096: URL: https://github.com/apache/kafka/pull/13096#discussion_r1067070504
########## core/src/main/scala/kafka/server/FetchSession.scala: ########## @@ -705,10 +705,7 @@ class FetchSessionCache(private val maxEntries: Int, } def remove(sessionId: Int): Option[FetchSession] = synchronized { - get(sessionId) match { - case None => None - case Some(session) => remove(session) - } + get(sessionId).flatMap(session => remove(session)) Review Comment: FYI reviewers - No new object allocation here inside Option.flatMap. Implementation of contains: ``` @inline final def flatMap[B](f: A => Option[B]): Option[B] = if (isEmpty) None else f(this.get) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org