Make NativeRandom an object instead of a class with companion
This commit is contained in:
committed by
Pavel Punegov
parent
8e4806725b
commit
71a601d87e
@@ -7,11 +7,10 @@ package kotlin.random
|
|||||||
import kotlin.native.concurrent.AtomicLong
|
import kotlin.native.concurrent.AtomicLong
|
||||||
import kotlin.system.getTimeNanos
|
import kotlin.system.getTimeNanos
|
||||||
|
|
||||||
internal class NativeRandom {
|
|
||||||
/**
|
/**
|
||||||
* A default pseudo-random linear congruential generator.
|
* The default implementation of pseudo-random generator using the linear congruential generator.
|
||||||
*/
|
*/
|
||||||
companion object : Random() {
|
internal object NativeRandom : Random() {
|
||||||
private const val MULTIPLIER = 0x5deece66dL
|
private const val MULTIPLIER = 0x5deece66dL
|
||||||
private val _seed = AtomicLong(mult(getTimeNanos()))
|
private val _seed = AtomicLong(mult(getTimeNanos()))
|
||||||
|
|
||||||
@@ -35,7 +34,6 @@ internal class NativeRandom {
|
|||||||
|
|
||||||
override fun nextInt(): Int = nextBits(32)
|
override fun nextInt(): Int = nextBits(32)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
internal actual fun defaultPlatformRandom(): Random = NativeRandom
|
internal actual fun defaultPlatformRandom(): Random = NativeRandom
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user