Skip to content

Commit ed9bbf6

Browse files
committed
Remove _pointer(to:as:)
1 parent 11b1106 commit ed9bbf6

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Sources/RandomKit/Internal/StackArray.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ internal func _zero8<T: ExpressibleByIntegerLiteral>() -> _Array8<T> {
7777

7878
/// Returns a mutable pointer to the contents of `array`.
7979
internal func _contents<T>(of array: inout _Array312<T>) -> UnsafeMutablePointer<T> {
80-
return _pointer(to: &array, as: T.self)
80+
return UnsafeMutablePointer(&array.0)
8181
}
8282

8383
/// Returns a mutable pointer to the contents of `array`.
8484
internal func _contents<T>(of array: inout _Array16<T>) -> UnsafeMutablePointer<T> {
85-
return _pointer(to: &array, as: T.self)
85+
return UnsafeMutablePointer(&array.0)
8686
}

Sources/RandomKit/Internal/Typecasting.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal func _unsafeBitCast<T, U>(_ value: T) -> U {
3434
// Allows casting between types of potentially different sizes.
3535

3636
internal func _unsafeCast<T, U>(_ value: inout T, to type: U.Type = U.self) -> U {
37-
return _pointer(to: &value, as: type).pointee
37+
return UnsafeMutableRawPointer(&value).assumingMemoryBound(to: type).pointee
3838
}
3939

4040
internal func _unsafeCast<T, U>(_ value: T, to type: U.Type = U.self) -> U {
@@ -47,6 +47,6 @@ internal func _unsafeValue<T>(of type: T.Type = T.self) -> T {
4747
return _unsafeCast(Optional<T>.none)
4848
}
4949

50-
internal func _pointer<T, U>(to value: inout T, as type: U.Type = U.self) -> UnsafeMutablePointer<U> {
51-
return UnsafeMutableRawPointer(&value).assumingMemoryBound(to: type)
52-
}
50+
//internal func _pointer<T, U>(to value: inout T, as type: U.Type = U.self) -> UnsafeMutablePointer<U> {
51+
// return UnsafeMutableRawPointer(&value).assumingMemoryBound(to: type)
52+
//}

Sources/RandomKit/Types/RandomGenerator/ChaCha.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ public struct ChaCha: RandomBytesGenerator, Seedable, SeedableFromSequence, Seed
7272
private var _index: Int
7373

7474
private var _bufferPointer: UnsafeMutablePointer<UInt32> {
75-
mutating get { return _pointer(to: &_buffer) }
75+
mutating get { return UnsafeMutablePointer(&_buffer.0) }
7676
}
7777

7878
private var _statePointer: UnsafeMutablePointer<UInt32> {
79-
mutating get { return _pointer(to: &_state) }
79+
mutating get { return UnsafeMutablePointer(&_state.0) }
8080
}
8181

8282
private init(_buffer: _State, _state: _State, _index: Int) {
@@ -94,7 +94,7 @@ public struct ChaCha: RandomBytesGenerator, Seedable, SeedableFromSequence, Seed
9494
/// Creates an instance seeded with `randomGenerator`.
9595
public init<R: RandomGenerator>(seededWith randomGenerator: inout R) {
9696
var seed: _Array8<UInt32> = randomGenerator.randomUnsafeValue()
97-
self.init(seed: UnsafeBufferPointer(start: _pointer(to: &seed), count: ChaCha._keyCount))
97+
self.init(seed: UnsafeBufferPointer(start: &seed.0, count: ChaCha._keyCount))
9898
}
9999

100100
private mutating func _reset() {

0 commit comments

Comments
 (0)