mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
Sources: Add unsafe keywords where needed
This commit is contained in:
301 files changed
+6051
-5498
No files matched your search
@@ -86,16 +86,16 @@ internal struct _HashStack<Element> {
|
||||
assert(level < _count)
|
||||
return withUnsafeBytes(of: &_contents) { buffer in
|
||||
// Homogeneous tuples are layout compatible with their element type
|
||||
let start = buffer.baseAddress!.assumingMemoryBound(to: Element.self)
|
||||
return start[Int(truncatingIfNeeded: level)]
|
||||
let start = unsafe buffer.baseAddress!.assumingMemoryBound(to: Element.self)
|
||||
return unsafe start[Int(truncatingIfNeeded: level)]
|
||||
}
|
||||
}
|
||||
set {
|
||||
assert(level < capacity)
|
||||
withUnsafeMutableBytes(of: &_contents) { buffer in
|
||||
// Homogeneous tuples are layout compatible with their element type
|
||||
let start = buffer.baseAddress!.assumingMemoryBound(to: Element.self)
|
||||
start[Int(truncatingIfNeeded: level)] = newValue
|
||||
let start = unsafe buffer.baseAddress!.assumingMemoryBound(to: Element.self)
|
||||
unsafe start[Int(truncatingIfNeeded: level)] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user