summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shai Barack <shayba@google.com> 2023-03-11 00:01:15 +0000
committer Shai Barack <shayba@google.com> 2023-03-19 20:06:14 +0000
commit73313c30151271d0d18c09715aab3af19e201d6e (patch)
tree4b3d8444034371fffeddbbbc8efa9e14b4736f06
parent2d4b18e60ade42c00d2ab7fe060a5393d8eb8304 (diff)
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
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt1
1 files changed, 1 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt b/packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt
index f3b7e0d24a6e..298dacde8128 100644
--- a/packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt
@@ -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)