Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Refactor: eliminate redundant Result.success(Unit).toString() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Pr0methean committed Oct 22, 2022
1 parent 05cf669 commit 65871e5
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import java.util.concurrent.atomic.AtomicReference
import javax.annotation.concurrent.GuardedBy
import kotlin.Result.Companion.failure

val SUCCESS_UNIT = Result.success(Unit)
val abstractTaskLogger: Logger = LogManager.getLogger("AbstractTask")
private val cancelBecauseReplacing = CancellationException("Being replaced")
abstract class AbstractTask<T>(final override val name: String, val cache: TaskCache<T>) : Task<T> {
Expand Down Expand Up @@ -152,7 +153,8 @@ abstract class AbstractTask<T>(final override val name: String, val cache: TaskC

@Suppress("DeferredResultUnused")
suspend inline fun emit(result: Result<T>, source: Deferred<Result<T>>?) {
abstractTaskLogger.debug("Locking {} to emit {}", this, result)
abstractTaskLogger.debug("Locking {} to emit {}", this,
if (SUCCESS_UNIT == result) "success(Unit)" else result)
mutex.withLock(result) {
if (cache.enabled && directDependentTasks.size < 2) {
abstractTaskLogger.info("Disabling caching for {} while emitting result", this)
Expand Down

0 comments on commit 65871e5

Please sign in to comment.