extensions: add unsafeLazy

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2021-05-30 02:18:00 +05:30
parent 4bc023ce3b
commit 6388bc7ac9
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -75,3 +75,6 @@ val RevCommit.time: Date
fun String.splitLines(): Array<String> { fun String.splitLines(): Array<String> {
return split("\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() return split("\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
} }
/** Alias to [lazy] with thread safety mode always set to [LazyThreadSafetyMode.NONE]. */
fun <T> unsafeLazy(initializer: () -> T) = lazy(LazyThreadSafetyMode.NONE) { initializer.invoke() }