Skip to content

Commit f428a16

Browse files
committed
tweaked local var names to avoid confusion with self's properties
1 parent 91fa717 commit f428a16

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

stdlib/public/core/ArrayBufferProtocol.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal protocol _ArrayBufferProtocol
7373
/// - Precondition: This buffer is backed by a uniquely-referenced
7474
/// `_ContiguousArrayBuffer`.
7575
mutating func replaceSubrange<C>(
76-
_ subRange: Range<Int>,
76+
_ subrange: Range<Int>,
7777
with newCount: Int,
7878
elementsOf newValues: C
7979
) where C : Collection, C.Iterator.Element == Element
@@ -134,32 +134,32 @@ extension _ArrayBufferProtocol {
134134
}
135135

136136
internal mutating func replaceSubrange<C>(
137-
_ subRange: Range<Int>,
137+
_ subrange: Range<Int>,
138138
with newCount: Int,
139139
elementsOf newValues: C
140140
) where C : Collection, C.Iterator.Element == Element {
141141
_sanityCheck(startIndex == 0, "_SliceBuffer should override this function.")
142142
let oldCount = self.count
143-
let eraseCount = subRange.count
143+
let eraseCount = subrange.count
144144

145145
let growth = newCount - eraseCount
146146
self.count = oldCount + growth
147147

148148
let elements = self.subscriptBaseAddress
149-
let oldTailIndex = subRange.upperBound
149+
let oldTailIndex = subrange.upperBound
150150
let oldTailStart = elements + oldTailIndex
151151
let newTailIndex = oldTailIndex + growth
152152
let newTailStart = oldTailStart + growth
153-
let tailCount = oldCount - subRange.upperBound
153+
let tailCount = oldCount - subrange.upperBound
154154

155155
if growth > 0 {
156156
// Slide the tail part of the buffer forwards, in reverse order
157157
// so as not to self-clobber.
158158
newTailStart.moveInitialize(from: oldTailStart, count: tailCount)
159159

160-
// Assign over the original subRange
160+
// Assign over the original subrange
161161
var i = newValues.startIndex
162-
for j in CountableRange(subRange) {
162+
for j in CountableRange(subrange) {
163163
elements[j] = newValues[i]
164164
newValues.formIndex(after: &i)
165165
}
@@ -171,8 +171,8 @@ extension _ArrayBufferProtocol {
171171
_expectEnd(i, newValues)
172172
}
173173
else { // We're not growing the buffer
174-
// Assign all the new elements into the start of the subRange
175-
var i = subRange.lowerBound
174+
// Assign all the new elements into the start of the subrange
175+
var i = subrange.lowerBound
176176
var j = newValues.startIndex
177177
for _ in 0..<newCount {
178178
elements[i] = newValues[j]
@@ -202,7 +202,7 @@ extension _ArrayBufferProtocol {
202202
// Assign over the start of the replaced range with the tail
203203
newTailStart.moveAssign(from: oldTailStart, count: tailCount)
204204

205-
// Destroy elements remaining after the tail in subRange
205+
// Destroy elements remaining after the tail in subrange
206206
(newTailStart + tailCount).deinitialize(
207207
count: shrinkage - tailCount)
208208
}

stdlib/public/core/Arrays.swift.gyb

+13-14
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ extension _ArrayBufferProtocol {
16761676
) where C.Iterator.Element == Element {
16771677

16781678
let growth = insertCount - bounds.count
1679-
let newCount = count + growth
1679+
let newCount = self.count + growth
16801680
var newBuffer = _forceCreateUniqueMutableBuffer(
16811681
newCount: newCount, requiredCapacity: newCount)
16821682

@@ -1866,7 +1866,6 @@ extension _ArrayBufferProtocol {
18661866
_sanityCheck(requiredCapacity >= countForBuffer)
18671867
_sanityCheck(minNewCapacity >= countForBuffer)
18681868

1869-
// FIXME(Typechecker): Swift. prefix shouldn't be necessary (rdar://problem/28947708)
18701869
let minimumCapacity = Swift.max(requiredCapacity,
18711870
minNewCapacity > capacity
18721871
? _growArrayCapacity(capacity) : capacity)
@@ -1996,8 +1995,7 @@ extension _ArrayBufferProtocol {
19961995

19971996
internal mutating func _arrayReserve(_ minimumCapacity: Int) {
19981997

1999-
let count = self.count
2000-
// FIXME(Typechecker): shouldn't need Swift. here
1998+
let oldCount = self.count
20011999
let requiredCapacity = Swift.max(count, minimumCapacity)
20022000

20032001
if _fastPath(
@@ -2008,8 +2006,9 @@ extension _ArrayBufferProtocol {
20082006
}
20092007

20102008
var newBuffer = _forceCreateUniqueMutableBuffer(
2011-
newCount: count, requiredCapacity: requiredCapacity)
2012-
_arrayOutOfPlaceUpdate(&newBuffer, count, 0, _IgnorePointer())
2009+
newCount: oldCount, requiredCapacity: requiredCapacity)
2010+
2011+
_arrayOutOfPlaceUpdate(&newBuffer, oldCount, 0, _IgnorePointer())
20132012
}
20142013

20152014
/// Append items from `newItems` to a buffer.
@@ -2025,22 +2024,22 @@ extension _ArrayBufferProtocol {
20252024
}
20262025

20272026
// This will force uniqueness
2028-
var count = self.count
2029-
self._arrayReserve(count + 1)
2027+
var newCount = self.count
2028+
_arrayReserve(newCount + 1)
20302029
while true {
2031-
let capacity = self.capacity
2030+
let currentCapacity = self.capacity
20322031
let base = self.firstElementAddress
20332032

2034-
while (nextItem != nil) && count < capacity {
2035-
(base + count).initialize(to: nextItem!)
2036-
count += 1
2033+
while (nextItem != nil) && newCount < currentCapacity {
2034+
(base + newCount).initialize(to: nextItem!)
2035+
newCount += 1
20372036
nextItem = stream.next()
20382037
}
2039-
self.count = count
2038+
self.count = newCount
20402039
if nextItem == nil {
20412040
return
20422041
}
2043-
self._arrayReserve(_growArrayCapacity(capacity))
2042+
self._arrayReserve(_growArrayCapacity(currentCapacity))
20442043
}
20452044
}
20462045
}

stdlib/public/core/SliceBuffer.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ internal struct _SliceBuffer<Element>
7979
/// - Precondition: This buffer is backed by a uniquely-referenced
8080
/// `_ContiguousArrayBuffer` and
8181
/// `insertCount <= numericCast(newValues.count)`.
82-
internal mutating func replace<C>(
83-
subRange: Range<Int>,
82+
internal mutating func replaceSubrange<C>(
83+
_ subrange: Range<Int>,
8484
with insertCount: Int,
8585
elementsOf newValues: C
8686
) where C : Collection, C.Iterator.Element == Element {
@@ -90,7 +90,7 @@ internal struct _SliceBuffer<Element>
9090

9191
_sanityCheck(_hasNativeBuffer && isUniquelyReferenced())
9292

93-
let eraseCount = subRange.count
93+
let eraseCount = subrange.count
9494
let growth = insertCount - eraseCount
9595
let oldCount = count
9696

@@ -99,8 +99,8 @@ internal struct _SliceBuffer<Element>
9999

100100
_sanityCheck(native.count + growth <= native.capacity)
101101

102-
let start = subRange.lowerBound - startIndex + hiddenElementCount
103-
let end = subRange.upperBound - startIndex + hiddenElementCount
102+
let start = subrange.lowerBound - startIndex + hiddenElementCount
103+
let end = subrange.upperBound - startIndex + hiddenElementCount
104104
native.replaceSubrange(
105105
start..<end,
106106
with: insertCount,

0 commit comments

Comments
 (0)