Skip to content

Commit 78b60fb

Browse files
committed
stdlib: Dictionary: simplify code and fix coding style
1 parent 0da6efd commit 78b60fb

File tree

1 file changed

+16
-31
lines changed

1 file changed

+16
-31
lines changed

stdlib/public/core/HashedCollections.swift.gyb

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,9 +2482,7 @@ internal struct _BitMap {
24822482
}
24832483

24842484
internal var numberOfWords: Int {
2485-
get {
2486-
return _BitMap.wordsFor(bitCount)
2487-
}
2485+
return _BitMap.wordsFor(bitCount)
24882486
}
24892487

24902488
internal func initializeToZero() {
@@ -2573,9 +2571,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
25732571
%end
25742572

25752573
internal var buffer: BufferPointer {
2576-
get {
2577-
return BufferPointer(self)
2578-
}
2574+
return BufferPointer(self)
25792575
}
25802576

25812577
// All underscored functions are unsafe and need a _fixLifetime in the caller.
@@ -2590,9 +2586,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
25902586

25912587
@_versioned
25922588
internal var _capacity: Int {
2593-
get {
2594-
return _body.capacity
2595-
}
2589+
return _body.capacity
25962590
}
25972591

25982592
@_versioned
@@ -2606,9 +2600,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
26062600
}
26072601

26082602
internal var _maxLoadFactorInverse : Double {
2609-
get {
2610-
return _body.maxLoadFactorInverse
2611-
}
2603+
return _body.maxLoadFactorInverse
26122604
}
26132605

26142606
internal
@@ -2654,7 +2646,7 @@ final internal class _Native${Self}StorageImpl<${TypeParameters}> :
26542646
let requiredCapacity =
26552647
bytesForBitMap(capacity: capacity) + bytesForKeys(capacity: capacity)
26562648
%if Self == 'Dictionary':
2657-
+ bytesForValues(capacity: capacity)
2649+
+ bytesForValues(capacity: capacity)
26582650
%end
26592651

26602652
let r = super.create(minimumCapacity: requiredCapacity) { _ in
@@ -2729,8 +2721,8 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
27292721
internal init(capacity: Int) {
27302722
buffer = StorageImpl.create(capacity: capacity)
27312723
initializedEntries = _BitMap(
2732-
storage: buffer._initializedHashtableEntriesBitMapStorage,
2733-
bitCount: capacity)
2724+
storage: buffer._initializedHashtableEntriesBitMapStorage,
2725+
bitCount: capacity)
27342726
keys = buffer._keys
27352727
%if Self == 'Dictionary':
27362728
values = buffer._values
@@ -2753,11 +2745,9 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
27532745
@_transparent
27542746
public // @testable
27552747
var capacity: Int {
2756-
get {
2757-
let result = buffer._capacity
2758-
_fixLifetime(buffer)
2759-
return result
2760-
}
2748+
let result = buffer._capacity
2749+
_fixLifetime(buffer)
2750+
return result
27612751
}
27622752

27632753
@_versioned
@@ -2776,11 +2766,9 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
27762766

27772767
@_transparent
27782768
internal var maxLoadFactorInverse: Double {
2779-
get {
2780-
let result = buffer._maxLoadFactorInverse
2781-
_fixLifetime(buffer)
2782-
return result
2783-
}
2769+
let result = buffer._maxLoadFactorInverse
2770+
_fixLifetime(buffer)
2771+
return result
27842772
}
27852773

27862774
@_versioned
@@ -3144,7 +3132,6 @@ internal struct _BridgedNative${Self}Storage {
31443132
internal let values: UnsafeMutablePointer<AnyObject>
31453133
%end
31463134

3147-
31483135
internal init(buffer: StorageImpl) {
31493136
self.buffer = buffer
31503137
initializedEntries = _BitMap(
@@ -3159,11 +3146,9 @@ internal struct _BridgedNative${Self}Storage {
31593146

31603147
@_transparent
31613148
internal var capacity: Int {
3162-
get {
3163-
let result = buffer._capacity
3164-
_fixLifetime(buffer)
3165-
return result
3166-
}
3149+
let result = buffer._capacity
3150+
_fixLifetime(buffer)
3151+
return result
31673152
}
31683153

31693154
@_versioned

0 commit comments

Comments
 (0)