Commit 18cc687d authored by Him188's avatar Him188

Make shortcuts inline

parent bd291a7d
...@@ -3,8 +3,9 @@ package net.mamoe.mirai.utils.internal ...@@ -3,8 +3,9 @@ package net.mamoe.mirai.utils.internal
/** /**
* 要求 [this] 最小为 [min]. * 要求 [this] 最小为 [min].
*/ */
@Suppress("NOTHING_TO_INLINE")
@PublishedApi @PublishedApi
internal fun Int.coerceAtLeastOrFail(min: Int): Int { internal inline fun Int.coerceAtLeastOrFail(min: Int): Int {
require(this >= min) require(this >= min)
return this return this
} }
...@@ -12,8 +13,9 @@ internal fun Int.coerceAtLeastOrFail(min: Int): Int { ...@@ -12,8 +13,9 @@ internal fun Int.coerceAtLeastOrFail(min: Int): Int {
/** /**
* 要求 [this] 最小为 [min]. * 要求 [this] 最小为 [min].
*/ */
@Suppress("NOTHING_TO_INLINE")
@PublishedApi @PublishedApi
internal fun Long.coerceAtLeastOrFail(min: Long): Long { internal inline fun Long.coerceAtLeastOrFail(min: Long): Long {
require(this >= min) require(this >= min)
return this return this
} }
...@@ -21,13 +23,15 @@ internal fun Long.coerceAtLeastOrFail(min: Long): Long { ...@@ -21,13 +23,15 @@ internal fun Long.coerceAtLeastOrFail(min: Long): Long {
/** /**
* 要求 [this] 最大为 [max]. * 要求 [this] 最大为 [max].
*/ */
@Suppress("NOTHING_TO_INLINE")
@PublishedApi @PublishedApi
internal fun Int.coerceAtMostOrFail(max: Int): Int = internal inline fun Int.coerceAtMostOrFail(max: Int): Int =
if (this >= max) error("value is greater than its expected maximum value $max") if (this >= max) error("value is greater than its expected maximum value $max")
else this else this
@Suppress("NOTHING_TO_INLINE")
@PublishedApi @PublishedApi
internal fun Long.coerceAtMostOrFail(max: Long): Long = internal inline fun Long.coerceAtMostOrFail(max: Long): Long =
if (this >= max) error("value is greater than its expected maximum value $max") if (this >= max) error("value is greater than its expected maximum value $max")
else this else this
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment