From 6388bc7ac93d3b302abe6598cfc6eef70a9fea3d Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sun, 30 May 2021 02:18:00 +0530 Subject: [PATCH] extensions: add unsafeLazy Signed-off-by: Harsh Shandilya --- .../main/java/dev/msfjarvis/aps/util/extensions/Extensions.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/dev/msfjarvis/aps/util/extensions/Extensions.kt b/app/src/main/java/dev/msfjarvis/aps/util/extensions/Extensions.kt index a6d0066c..f04dba33 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/extensions/Extensions.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/extensions/Extensions.kt @@ -75,3 +75,6 @@ val RevCommit.time: Date fun String.splitLines(): Array { return split("\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() } + +/** Alias to [lazy] with thread safety mode always set to [LazyThreadSafetyMode.NONE]. */ +fun unsafeLazy(initializer: () -> T) = lazy(LazyThreadSafetyMode.NONE) { initializer.invoke() }