From b861c991127d67ebd9a404ef32efdb719cc2e675 Mon Sep 17 00:00:00 2001 From: Jules Ivanic Date: Tue, 26 Nov 2024 19:27:51 +1100 Subject: [PATCH] [Internal] Micro-optimisation: Reuse previously calculated `java.langSystem.nanoTime` (#1407) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hey :) I'm not contributing much anymore. Sorry about that. I lost the motivation, TBH, but I really enjoy following what you continue to do 👏 I was passing by and was reading some of the new code when I saw this. LMKWYT :) With this change, we lose some nanoseconds of precision, so it might not be the expected behaviour. 🤔 --- .../src/main/scala/zio/kafka/consumer/internal/Runloop.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zio-kafka/src/main/scala/zio/kafka/consumer/internal/Runloop.scala b/zio-kafka/src/main/scala/zio/kafka/consumer/internal/Runloop.scala index 8d45f8e55..945a9ce11 100644 --- a/zio-kafka/src/main/scala/zio/kafka/consumer/internal/Runloop.scala +++ b/zio-kafka/src/main/scala/zio/kafka/consumer/internal/Runloop.scala @@ -327,7 +327,7 @@ private[consumer] final class Runloop private ( for { p <- Promise.make[Throwable, Unit] startTime = java.lang.System.nanoTime() - _ <- commitQueue.offer(Runloop.Commit(java.lang.System.nanoTime(), offsets, p)) + _ <- commitQueue.offer(Runloop.Commit(startTime, offsets, p)) _ <- commandQueue.offer(RunloopCommand.CommitAvailable) _ <- diagnostics.emit(DiagnosticEvent.Commit.Started(offsets)) _ <- p.await.timeoutFail(CommitTimeout)(commitTimeout)