[Arrays] Use _assumeNonNegative on capacity properties

I’m not convinced this has a real effect, but.
This commit is contained in:
Karoy Lorentey committed 2025-08-29 17:13:34 -07:00
1 parent 3ff65774bd
commit 5cd51978a4
2 files changed
+10 -6

No files matched your search

+4 -2
View File
@@ -123,11 +123,13 @@ extension DynamicArray /*where Element: Copyable*/ {
extension DynamicArray where Element: ~Copyable {
@inlinable
@inline(__always)
public var capacity: Int { _storage.capacity }
public var capacity: Int { _assumeNonNegative(_storage.capacity) }
@inlinable
@inline(__always)
public var freeCapacity: Int { _storage.capacity - _storage.count }
public var freeCapacity: Int {
_assumeNonNegative(_storage.capacity &- _storage.count)
}
}
//MARK: - Span creation