Skip to content

Prefix countRepresentedWords with underscore [NFC] #10481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/public/core/DoubleWidth.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ public struct DoubleWidth<Base : FixedWidthInteger> :
}

// TODO: move to Int128 just like init(_builtinIntegerLiteral:) ?
return (n < _storage.low.countRepresentedWords) ?
return (n < _storage.low._countRepresentedWords) ?
_storage.low._word(at: n) :
_storage.high._word(at: n - _storage.low.countRepresentedWords)
_storage.high._word(at: n - _storage.low._countRepresentedWords)
}
}

Expand Down
12 changes: 6 additions & 6 deletions stdlib/public/core/Integers.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ extension BinaryInteger {
///
/// This property is a constant for instances of fixed-width integer types.
@_transparent
public var countRepresentedWords: Int {
public var _countRepresentedWords: Int {
return (self.bitWidth + ${word_bits} - 1) / ${word_bits}
}

Expand Down Expand Up @@ -1896,11 +1896,11 @@ extension BinaryInteger {
}

// FIXME(integers): inefficient. Should get rid of _word(at:) and
// countRepresentedWords, and make `words` the basic operation.
// _countRepresentedWords, and make `words` the basic operation.
public var words: [UInt] {
var result = [UInt]()
result.reserveCapacity(countRepresentedWords)
for i in 0..<self.countRepresentedWords {
result.reserveCapacity(_countRepresentedWords)
for i in 0..<self._countRepresentedWords {
result.append(_word(at: i))
}
return result
Expand Down Expand Up @@ -2328,7 +2328,7 @@ ${unsafeOperationComment(x.operator)}
else {
var result: Self = source < (0 as T) ? ~0 : 0
// start with the most significant word
var n = source.countRepresentedWords
var n = source._countRepresentedWords
while n >= 0 {
// masking is OK here because this we have already ensured
// that Self.bitWidth > ${word_bits}. Not masking results in
Expand Down Expand Up @@ -2801,7 +2801,7 @@ ${assignmentOperatorComment(x.operator, True)}
@_transparent
public func _word(at n: Int) -> UInt {
_precondition(n >= 0, "Negative word index")
if _fastPath(n < countRepresentedWords) {
if _fastPath(n < _countRepresentedWords) {
let shift = UInt(n._value) &* ${word_bits}
let bitWidth = UInt(self.bitWidth._value)
_sanityCheck(shift < bitWidth)
Expand Down
2 changes: 1 addition & 1 deletion test/Prototypes/BigInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public struct _BigInt<Word: FixedWidthInteger & UnsignedInteger> :
// FIXME: This is broken on 32-bit arch w/ Word = UInt64
let wordRatio = UInt.bitWidth / Word.bitWidth
_sanityCheck(wordRatio != 0)
for i in 0..<source.countRepresentedWords {
for i in 0..<source._countRepresentedWords {
var sourceWord = source._word(at: i)
for _ in 0..<wordRatio {
_data.append(Word(extendingOrTruncating: sourceWord))
Expand Down