From 65871e5f89833d997879d31357b7ed87b00ae67c Mon Sep 17 00:00:00 2001 From: Chris Hennick Date: Fri, 21 Oct 2022 18:37:35 -0700 Subject: [PATCH] Refactor: eliminate redundant Result.success(Unit).toString() calls --- .../kotlin/io/github/pr0methean/ochd/tasks/AbstractTask.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/io/github/pr0methean/ochd/tasks/AbstractTask.kt b/src/main/kotlin/io/github/pr0methean/ochd/tasks/AbstractTask.kt index b4088e66a..84b5b49de 100644 --- a/src/main/kotlin/io/github/pr0methean/ochd/tasks/AbstractTask.kt +++ b/src/main/kotlin/io/github/pr0methean/ochd/tasks/AbstractTask.kt @@ -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(final override val name: String, val cache: TaskCache) : Task { @@ -152,7 +153,8 @@ abstract class AbstractTask(final override val name: String, val cache: TaskC @Suppress("DeferredResultUnused") suspend inline fun emit(result: Result, source: Deferred>?) { - 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)