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

Commit db17068

Browse files
committed
Refactor: eliminate redundant Result.success(Unit).toString() calls
(cherry picked from commit 65871e5)
1 parent 3fa7a61 commit db17068

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎src/main/kotlin/io/github/pr0methean/ochd/tasks/AbstractTask.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import java.util.concurrent.atomic.AtomicReference
1313
import javax.annotation.concurrent.GuardedBy
1414
import kotlin.Result.Companion.failure
1515

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

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

0 commit comments

Comments
 (0)