mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
stdlib: Dictionary: simplify code and fix coding style
This commit is contained in:
@@ -2482,9 +2482,7 @@ internal struct _BitMap {
|
||||
}
|
||||
|
||||
internal var numberOfWords: Int {
|
||||
get {
|
||||
return _BitMap.wordsFor(bitCount)
|
||||
}
|
||||
return _BitMap.wordsFor(bitCount)
|
||||
}
|
||||
|
||||
internal func initializeToZero() {
|
||||
@@ -2573,9 +2571,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
|
||||
%end
|
||||
|
||||
internal var buffer: BufferPointer {
|
||||
get {
|
||||
return BufferPointer(self)
|
||||
}
|
||||
return BufferPointer(self)
|
||||
}
|
||||
|
||||
// All underscored functions are unsafe and need a _fixLifetime in the caller.
|
||||
@@ -2590,9 +2586,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
|
||||
|
||||
@_versioned
|
||||
internal var _capacity: Int {
|
||||
get {
|
||||
return _body.capacity
|
||||
}
|
||||
return _body.capacity
|
||||
}
|
||||
|
||||
@_versioned
|
||||
@@ -2606,9 +2600,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
|
||||
}
|
||||
|
||||
internal var _maxLoadFactorInverse : Double {
|
||||
get {
|
||||
return _body.maxLoadFactorInverse
|
||||
}
|
||||
return _body.maxLoadFactorInverse
|
||||
}
|
||||
|
||||
internal
|
||||
@@ -2654,7 +2646,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
|
||||
let requiredCapacity =
|
||||
bytesForBitMap(capacity: capacity) + bytesForKeys(capacity: capacity)
|
||||
%if Self == 'Dictionary':
|
||||
+ bytesForValues(capacity: capacity)
|
||||
+ bytesForValues(capacity: capacity)
|
||||
%end
|
||||
|
||||
let r = super.create(minimumCapacity: requiredCapacity) { _ in
|
||||
@@ -2729,8 +2721,8 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
internal init(capacity: Int) {
|
||||
buffer = StorageImpl.create(capacity: capacity)
|
||||
initializedEntries = _BitMap(
|
||||
storage: buffer._initializedHashtableEntriesBitMapStorage,
|
||||
bitCount: capacity)
|
||||
storage: buffer._initializedHashtableEntriesBitMapStorage,
|
||||
bitCount: capacity)
|
||||
keys = buffer._keys
|
||||
%if Self == 'Dictionary':
|
||||
values = buffer._values
|
||||
@@ -2753,11 +2745,9 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
@_transparent
|
||||
public // @testable
|
||||
var capacity: Int {
|
||||
get {
|
||||
let result = buffer._capacity
|
||||
_fixLifetime(buffer)
|
||||
return result
|
||||
}
|
||||
let result = buffer._capacity
|
||||
_fixLifetime(buffer)
|
||||
return result
|
||||
}
|
||||
|
||||
@_versioned
|
||||
@@ -2776,11 +2766,9 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
|
||||
|
||||
@_transparent
|
||||
internal var maxLoadFactorInverse: Double {
|
||||
get {
|
||||
let result = buffer._maxLoadFactorInverse
|
||||
_fixLifetime(buffer)
|
||||
return result
|
||||
}
|
||||
let result = buffer._maxLoadFactorInverse
|
||||
_fixLifetime(buffer)
|
||||
return result
|
||||
}
|
||||
|
||||
@_versioned
|
||||
@@ -3144,7 +3132,6 @@ internal struct _BridgedNative${Self}Storage {
|
||||
internal let values: UnsafeMutablePointer<AnyObject>
|
||||
%end
|
||||
|
||||
|
||||
internal init(buffer: StorageImpl) {
|
||||
self.buffer = buffer
|
||||
initializedEntries = _BitMap(
|
||||
@@ -3159,11 +3146,9 @@ internal struct _BridgedNative${Self}Storage {
|
||||
|
||||
@_transparent
|
||||
internal var capacity: Int {
|
||||
get {
|
||||
let result = buffer._capacity
|
||||
_fixLifetime(buffer)
|
||||
return result
|
||||
}
|
||||
let result = buffer._capacity
|
||||
_fixLifetime(buffer)
|
||||
return result
|
||||
}
|
||||
|
||||
@_versioned
|
||||
|
||||
Reference in New Issue
Block a user