Skip to content

Commit

Permalink
Merge pull request #501 from kevin-lee/task/500/remove-unnecessary-eval
Browse files Browse the repository at this point in the history
Close #500 - Remove unnecessary re-evaluation of `String` in `logS`
  • Loading branch information
kevin-lee authored Nov 7, 2023
2 parents 47a0ad1 + 2889187 commit 2865629
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ trait Log[F[*]] {
)(toLeveledMessage: (String => LogMessage with NotIgnorable) with LogMessage.LeveledMessage.Leveled): F[String] =
toLeveledMessage.toLazyInput(message) match {
case LogMessage.LeveledMessage(msg, level) =>
map0(EF.effectOf(canLog.getLogger(level)(msg())))(_ => message)
lazy val messageString = msg()
map0(EF.effectOf(canLog.getLogger(level)(messageString)))(_ => messageString)
}

def logS_(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ trait Log[F[*]] {
def logS(message: => String)(toLeveledMessage: (String => LeveledMessage) with LeveledMessage.Leveled): F[String] =
toLeveledMessage.toLazyInput(message) match {
case LeveledMessage(msg, level) =>
map0(EF.effectOf(canLog.getLogger(level)(msg())))(_ => message)
lazy val messageString = msg()
map0(EF.effectOf(canLog.getLogger(level)(messageString)))(_ => messageString)
}

def logS_(message: => String)(toLeveledMessage: (String => LeveledMessage) with LeveledMessage.Leveled): F[Unit] =
Expand Down

0 comments on commit 2865629

Please sign in to comment.