Suppress inline warning
Without this suppression, building the code prints: ``` frameworks/base/packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt:29:1: warning: expected performance impact from inlining is insignificant. Inlining works best for functions with parameters of functional types inline fun <T> Optional<T>.getOrNull(): T? = orElse(null) ^ ``` Reviewing the documentation here: https://kotlinlang.org/docs/inline-functions.html It seems that the inline warning fires if there are no inlinable function parameters and no reified type parameters, as is the case here. However the original author of the code still thinks this is a reasonable target for inlining as a short method and a common utility, and I don't disagree. I'm suppressing the warning because it seems to be unhelpful, and because build warnings are considered tech debt as per: go/battledroids#clean-up-build-warnings Test: built, warning no longer appears Bug: 217776569 Change-Id: Ic94f4e7d1612679c67e7aaaa46dc884f2f60b7d4
This commit is contained in:
@@ -26,4 +26,5 @@ inline fun <T : Any, R> transform(value: T?, block: (T) -> R): R? = value?.let(b
|
||||
/**
|
||||
* Assists type-checking to unpack a Java Optional into T?
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun <T> Optional<T>.getOrNull(): T? = orElse(null)
|
||||
|
||||
Reference in New Issue
Block a user