Rename poll to removeFirstOrNull

This is more consistent with the Kotlin standard library.

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent 7d04774d60
commit 65194fae43
  1. 2
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/analysis/DataFlowAnalyzer.kt
  2. 2
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt
  3. 2
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/UnusedMethodTransformer.kt
  4. 2
      game/src/main/kotlin/org/openrs2/game/net/js5/Js5Service.kt
  5. 2
      util/src/main/kotlin/org/openrs2/util/collect/UniqueQueue.kt
  6. 16
      util/src/test/kotlin/org/openrs2/util/collect/UniqueQueueTest.kt

@ -50,7 +50,7 @@ public abstract class DataFlowAnalyzer<T>(owner: String, private val method: Met
workList += graph.vertexSet().filter { vertex -> graph.inDegreeOf(vertex) == 0 } workList += graph.vertexSet().filter { vertex -> graph.inDegreeOf(vertex) == 0 }
while (true) { while (true) {
val node = workList.poll() ?: break val node = workList.removeFirstOrNull() ?: break
val predecessors = graph.incomingEdgesOf(node).map { edge -> val predecessors = graph.incomingEdgesOf(node).map { edge ->
outSets[graph.getEdgeSource(edge)] ?: initialSet outSets[graph.getEdgeSource(edge)] ?: initialSet

@ -72,7 +72,7 @@ public class ConstantArgTransformer @Inject constructor(private val profile: Pro
queueEntryPoints(classPath) queueEntryPoints(classPath)
while (true) { while (true) {
val method = pendingMethods.poll() ?: break val method = pendingMethods.removeFirstOrNull() ?: break
analyzeMethod(classPath, method) analyzeMethod(classPath, method)
} }
} }

@ -31,7 +31,7 @@ public class UnusedMethodTransformer @Inject constructor(private val profile: Pr
queueEntryPoints(classPath) queueEntryPoints(classPath)
while (true) { while (true) {
val method = pendingMethods.poll() ?: break val method = pendingMethods.removeFirstOrNull() ?: break
analyzeMethod(classPath, method) analyzeMethod(classPath, method)
} }
} }

@ -36,7 +36,7 @@ public class Js5Service @Inject constructor(
return return
} }
val next = clients.poll() val next = clients.removeFirstOrNull()
if (next == null) { if (next == null) {
lock.wait() lock.wait()
continue continue

@ -27,7 +27,7 @@ public class UniqueQueue<T> {
addAll(vs) addAll(vs)
} }
public fun poll(): T? { public fun removeFirstOrNull(): T? {
val v = queue.removeFirstOrNull() val v = queue.removeFirstOrNull()
if (v != null) { if (v != null) {
set.remove(v) set.remove(v)

@ -8,15 +8,15 @@ import kotlin.test.assertTrue
class UniqueQueueTest { class UniqueQueueTest {
@Test @Test
fun testAddPoll() { fun testAddRemove() {
val queue = UniqueQueue<String>() val queue = UniqueQueue<String>()
assertTrue(queue.add("a")) assertTrue(queue.add("a"))
assertTrue(queue.add("b")) assertTrue(queue.add("b"))
assertFalse(queue.add("a")) assertFalse(queue.add("a"))
assertEquals("a", queue.poll()) assertEquals("a", queue.removeFirstOrNull())
assertEquals("b", queue.poll()) assertEquals("b", queue.removeFirstOrNull())
assertNull(queue.poll()) assertNull(queue.removeFirstOrNull())
} }
@Test @Test
@ -24,9 +24,9 @@ class UniqueQueueTest {
val queue = UniqueQueue<String>() val queue = UniqueQueue<String>()
queue.addAll(listOf("a", "b", "a")) queue.addAll(listOf("a", "b", "a"))
assertEquals("a", queue.poll()) assertEquals("a", queue.removeFirstOrNull())
assertEquals("b", queue.poll()) assertEquals("b", queue.removeFirstOrNull())
assertNull(queue.poll()) assertNull(queue.removeFirstOrNull())
} }
@Test @Test
@ -36,6 +36,6 @@ class UniqueQueueTest {
queue.clear() queue.clear()
assertNull(queue.poll()) assertNull(queue.removeFirstOrNull())
} }
} }

Loading…
Cancel
Save