Skip to content

Commit 67365d3

Browse files
committed
cleanup
1 parent 458e4a3 commit 67365d3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

common/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ class BuildTask @Ta5kBuilder constructor(
6767
override val name: String get() = "Building $blueprint with ${(breaks / (age / 20.0 + 0.001)).string} b/s ${(placements / (age / 20.0 + 0.001)).string} p/s"
6868

6969
private val pendingInteractions = ConcurrentLinkedQueue<BuildContext>()
70+
private val emptyPendingInteractionSlots
71+
get() = (build.maxPendingInteractions - pendingInteractions.size).coerceAtLeast(0)
72+
private val atMaxPendingInteractions
73+
get() = pendingInteractions.size >= build.maxPendingInteractions
7074

7175
private var placements = 0
7276
private var breaks = 0
@@ -127,7 +131,7 @@ class BuildTask @Ta5kBuilder constructor(
127131
}
128132

129133
is BuildResult.Contextual -> {
130-
if (pendingInteractions.size >= build.maxPendingInteractions) return@onRotate
134+
if (atMaxPendingInteractions) return@onRotate
131135
when (bestResult) {
132136
is BreakResult.Break -> {
133137
val breakResults = resultsNotBlocked
@@ -136,10 +140,10 @@ class BuildTask @Ta5kBuilder constructor(
136140
if (build.breakSettings.breaksPerTick > 1) {
137141
val takeCount = build.breakSettings
138142
.breaksPerTick
139-
.coerceAtMost((build.maxPendingInteractions - pendingInteractions.size))
143+
.coerceAtMost(emptyPendingInteractionSlots)
140144
val instantResults = breakResults
141145
.filter { it.context.instantBreak }
142-
.take(takeCount.coerceAtLeast(0))
146+
.take(takeCount)
143147

144148
if (instantResults.isNotEmpty()) {
145149
build.breakSettings.request(

0 commit comments

Comments
 (0)