File tree Expand file tree Collapse file tree 3 files changed +11
-28
lines changed
test/api-digester/Outputs Expand file tree Collapse file tree 3 files changed +11
-28
lines changed Original file line number Diff line number Diff line change @@ -61,27 +61,6 @@ public protocol RandomNumberGenerator {
6161 ///
6262 /// - Returns: An unsigned 64-bit random value.
6363 mutating func next( ) -> UInt64
64-
65- // FIXME: De-underscore after swift-evolution amendment
66- mutating func _fill( bytes buffer: UnsafeMutableRawBufferPointer )
67- }
68-
69- extension RandomNumberGenerator {
70- @inlinable
71- public mutating func _fill( bytes buffer: UnsafeMutableRawBufferPointer ) {
72- // FIXME: Optimize
73- var chunk : UInt64 = 0
74- var chunkBytes = 0
75- for i in 0 ..< buffer. count {
76- if chunkBytes == 0 {
77- chunk = next ( )
78- chunkBytes = UInt64 . bitWidth / 8
79- }
80- buffer [ i] = UInt8 ( truncatingIfNeeded: chunk)
81- chunk >>= UInt8 . bitWidth
82- chunkBytes -= 1
83- }
84- }
8564}
8665
8766extension RandomNumberGenerator {
@@ -167,11 +146,4 @@ public struct SystemRandomNumberGenerator : RandomNumberGenerator {
167146 swift_stdlib_random ( & random, MemoryLayout< UInt64> . size)
168147 return random
169148 }
170-
171- @inlinable
172- public mutating func _fill( bytes buffer: UnsafeMutableRawBufferPointer ) {
173- if !buffer. isEmpty {
174- swift_stdlib_random ( buffer. baseAddress!, buffer. count)
175- }
176- }
177149}
Original file line number Diff line number Diff line change @@ -78,3 +78,6 @@ Protocol _NSStringCore has been removed
7878
7979Constructor ManagedBuffer.init(_doNotCallMe:) has been removed
8080Func _makeAnyHashableUpcastingToHashableBaseType(_:storingResultInto:) has been removed
81+
82+ Func RandomNumberGenerator._fill(bytes:) has been removed
83+ Func SystemRandomNumberGenerator._fill(bytes:) has been removed
Original file line number Diff line number Diff line change 33
44import StdlibUnittest
55import StdlibCollectionUnittest
6+ import SwiftShims // for swift_stdlib_random
67
78let RandomTests = TestSuite ( " Random " )
89
910// _fill(bytes:)
1011
12+ extension RandomNumberGenerator {
13+ func _fill( bytes buffer: UnsafeMutableRawBufferPointer ) {
14+ guard let start = buffer. baseAddress else { return }
15+ swift_stdlib_random ( start, buffer. count)
16+ }
17+ }
18+
1119RandomTests . test ( " _fill(bytes:) " ) {
1220 for count in [ 100 , 1000 ] {
1321 var bytes1 = [ UInt8] ( repeating: 0 , count: count)
You can’t perform that action at this time.
0 commit comments