Skip to content

Commit 0267812

Browse files
committed
Don't make unnecessary NULL unboxings
1 parent 8684cad commit 0267812

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

IntelliJ-patches.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Some logic related to instrumentation was extracted to separate methods so that
7575
- `kotlinx.coroutines.flow.internal.FlowValueWrapperInternalKt.unwrapInternalDebuggerCapture` -- unwraps passed argument so it returns the original value; only used after transformation
7676
- `kotlinx.coroutines.flow.internal.FlowValueWrapperInternalKt.unwrapTyped` -- utility function served to ease casting to a real underlying type
7777
- `kotlinx.coroutines.flow.internal.FlowValueWrapperInternalKt.emitInternal(FlowCollector, value)` -- alternative of a regular `FlowCollector.emit` that supports insertion points; if there is a `FlowCollector`, its `emit` call can be replaced with `emitInternal` so this case would also be supported for constructing async stack traces
78-
- `kotlinx.coroutines.flow.internal.FlowValueWrapperInternalKt.debuggerCapture` -- common insertion point for a debugger agent; simplifies instrumentation; the value is always being unwrapped inside. `emitInternal` uses this method.
78+
- `kotlinx.coroutines.flow.internal.FlowValueWrapperInternalKt.debuggerCapture` -- common insertion point for a debugger agent; simplifies instrumentation; the value is always being unwrapped inside.
7979

8080
One internal method was added to `BufferedChannel`: `emitAllInternal`. This method ensures the value will be unwrapped in an insertion point.
8181

kotlinx-coroutines-core/common/src/channels/BufferedChannel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,7 @@ internal open class BufferedChannel<E>(
15431543
@Suppress("UNCHECKED_CAST")
15441544
private val onUndeliveredElementReceiveCancellationConstructor: OnCancellationConstructor? = onUndeliveredElement?.let {
15451545
{ select: SelectInstance<*>, _: Any?, element: Any? ->
1546-
{ if (element !== CHANNEL_CLOSED) onUndeliveredElement.callUndeliveredElement(element as E, select.context) }
1546+
{ if (element !== CHANNEL_CLOSED) onUndeliveredElement.callUndeliveredElement(unwrapTyped(element), select.context) }
15471547
}
15481548
}
15491549

kotlinx-coroutines-core/common/src/flow/internal/FlowValueWrapperInternal.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ private fun unwrapInternalDebuggerCapture(value: Any?): Any? {
3636

3737
// Shouldn't be inlined, the method is instrumented by the IDEA debugger agent
3838
internal suspend fun <T> FlowCollector<T>.emitInternal(value: Any?) {
39-
debuggerCapture<T, Unit>(value) { emit(it) }
39+
emit(unwrapTyped<T>(value))
4040
}
4141

4242
// Shouldn't be inlined, the method is instrumented by the IDEA debugger agent
4343
internal suspend fun <Unwrapped, R> debuggerCapture(value: Any?, block: suspend (Unwrapped) -> R): R {
44-
return block(unwrapTyped<Unwrapped>(value))
44+
return block(unwrapInternal(value) as Unwrapped)
4545
}

0 commit comments

Comments
 (0)