improve stdlib hygiene a bit.

Swift SVN r28392
This commit is contained in:
Chris Lattner
2015-05-10 02:55:18 +00:00
parent 1968b85a03
commit c1df892d47
44 changed files with 135 additions and 138 deletions

View File

@@ -743,7 +743,7 @@ struct _ParentProcess {
testPassed = false
testFailureExplanation = "the test crashed unexpectedly"
case (_, .Some(let status), true):
case (_, .Some(_), true):
testPassed = !_anyExpectFailed
}
if testPassed && t.crashOutputMatches.count > 0 {
@@ -1010,9 +1010,9 @@ public enum OSVersion : CustomStringConvertible {
public var description: String {
switch self {
case OSX(var major, var minor, var bugFix):
case OSX(let major, let minor, let bugFix):
return "OS X \(major).\(minor).\(bugFix)"
case iOS(var major, var minor, var bugFix):
case iOS(let major, let minor, let bugFix):
return "iOS \(major).\(minor).\(bugFix)"
case iOSSimulator:
return "iOSSimulator"

View File

@@ -26,14 +26,14 @@ public struct _FDInputStream {
public mutating func getline() -> String? {
if let newlineIndex =
_buffer[0..<_bufferUsed].indexOf(UInt8(UnicodeScalar("\n").value)) {
var result = String._fromWellFormedCodeUnitSequence(
let result = String._fromWellFormedCodeUnitSequence(
UTF8.self, input: _buffer[0..<newlineIndex])
_buffer.removeRange(0...newlineIndex)
_bufferUsed -= newlineIndex + 1
return result
}
if isEOF && _bufferUsed > 0 {
var result = String._fromWellFormedCodeUnitSequence(
let result = String._fromWellFormedCodeUnitSequence(
UTF8.self, input: _buffer[0..<_bufferUsed])
_buffer.removeAll()
_bufferUsed = 0

View File

@@ -152,9 +152,9 @@ public enum ProcessTerminationStatus : CustomStringConvertible {
public var description: String {
switch self {
case .Exit(var status):
case .Exit(let status):
return "Exit(\(status))"
case .Signal(var signal):
case .Signal(let signal):
return "Signal(\(_signalToString(signal)))"
}
}

View File

@@ -30,7 +30,7 @@ public struct MsgPackEncoder {
internal mutating func _appendBigEndian(value: Swift.UInt64) {
var x = value.byteSwapped
for i in 0..<8 {
for _ in 0..<8 {
bytes.append(UInt8(truncatingBitPattern: x))
x >>= 8
}
@@ -38,7 +38,7 @@ public struct MsgPackEncoder {
internal mutating func _appendBigEndian(value: Swift.UInt32) {
var x = value.byteSwapped
for i in 0..<4 {
for _ in 0..<4 {
bytes.append(UInt8(truncatingBitPattern: x))
x >>= 8
}
@@ -46,7 +46,7 @@ public struct MsgPackEncoder {
internal mutating func _appendBigEndian(value: Swift.UInt16) {
var x = value.byteSwapped
for i in 0..<2 {
for _ in 0..<2 {
bytes.append(UInt8(truncatingBitPattern: x))
x >>= 8
}
@@ -316,7 +316,7 @@ public struct MsgPackDecoder {
internal mutating func _readBigEndianUInt16() -> UInt16? {
if _haveNBytes(2) {
var result: UInt16 = 0
for i in 0..<2 {
for _ in 0..<2 {
result <<= 8
result |= UInt16(_consumeByte()!)
}
@@ -328,7 +328,7 @@ public struct MsgPackDecoder {
internal mutating func _readBigEndianUInt32() -> UInt32? {
if _haveNBytes(4) {
var result: UInt32 = 0
for i in 0..<4 {
for _ in 0..<4 {
result <<= 8
result |= UInt32(_consumeByte()!)
}
@@ -347,7 +347,7 @@ public struct MsgPackDecoder {
internal mutating func _readBigEndianUInt64() -> UInt64? {
if _haveNBytes(8) {
var result: UInt64 = 0
for i in 0..<8 {
for _ in 0..<8 {
result <<= 8
result |= UInt64(_consumeByte()!)
}
@@ -805,7 +805,7 @@ public enum MsgPackVariant {
if let count = decoder.readBeginArray() {
var array: [MsgPackVariant] = []
array.reserveCapacity(count)
for i in 0..<count {
for _ in 0..<count {
let maybeValue = MsgPackVariant._deserializeFrom(&decoder)
if let value = maybeValue {
array.append(value)
@@ -819,11 +819,10 @@ public enum MsgPackVariant {
if let count = decoder.readBeginMap() {
var map: [(MsgPackVariant, MsgPackVariant)] = []
map.reserveCapacity(count)
for i in 0..<count {
for _ in 0..<count {
let maybeKey = MsgPackVariant._deserializeFrom(&decoder)
let maybeValue = MsgPackVariant._deserializeFrom(&decoder)
if let key = maybeKey, value = maybeValue {
let keyValue = (key, value)
map.append(key, value)
} else {
return nil

View File

@@ -103,7 +103,7 @@ struct _NSViewMirror : MirrorType {
_NSViewMirror._views.addObject(_v)
let bounds = _v.bounds
if var b = _v.bitmapImageRepForCachingDisplayInRect(bounds) {
if let b = _v.bitmapImageRepForCachingDisplayInRect(bounds) {
_v.cacheDisplayInRect(bounds, toBitmapImageRep: b)
result = .Some(.View(b))
}

View File

@@ -515,7 +515,7 @@ extension Array : _ObjectiveCBridgeable {
inout result: Array?
) -> Bool {
// Construct the result array by conditionally bridging each element.
var anyObjectArr = [AnyObject](_fromNSArray: source)
let anyObjectArr = [AnyObject](_fromNSArray: source)
result = _arrayConditionalCast(anyObjectArr)
return result != nil
@@ -712,7 +712,7 @@ final public class NSFastGenerator : GeneratorType {
refresh()
if count == 0 { return .None }
}
var next : AnyObject = state[0].itemsPtr[n]!
let next : AnyObject = state[0].itemsPtr[n]!
++n
return next
}
@@ -934,7 +934,7 @@ extension NSDictionary : SequenceType {
switch _fastGenerator.next() {
case .None:
return .None
case .Some(var key):
case .Some(let key):
// Deliberately avoid the subscript operator in case the dictionary
// contains non-copyable keys. This is rare since NSMutableDictionary
// requires them, but we don't want to paint ourselves into a corner.

View File

@@ -21,7 +21,7 @@
//
func _toNSArray<T, U : AnyObject>(a: [T], @noescape f: (T) -> U) -> NSArray {
var result = NSMutableArray(capacity: a.count)
let result = NSMutableArray(capacity: a.count)
for s in a {
result.addObject(f(s))
}

View File

@@ -196,7 +196,7 @@ func __pushAutoreleasePool() -> COpaquePointer
func __popAutoreleasePool(pool: COpaquePointer)
public func autoreleasepool(@noescape code: () -> ()) {
var pool = __pushAutoreleasePool()
let pool = __pushAutoreleasePool()
code()
__popAutoreleasePool(pool)
}

View File

@@ -21,7 +21,7 @@ extension CIFilter {
// arguments args: [AnyObject]!,
// options dict: Dictionary<NSObject, AnyObject>!) -> CIImage!
func apply(k: CIKernel!, args: [AnyObject]!, options: (NSCopying, AnyObject)...) -> CIImage {
var dict = NSMutableDictionary()
let dict = NSMutableDictionary()
for (key, value) in options {
dict[key] = value
}
@@ -32,7 +32,7 @@ extension CIFilter {
@availability(OSX, introduced=10.10)
convenience init(name: String!,
elements: (NSCopying, AnyObject)...) {
var dict = NSMutableDictionary()
let dict = NSMutableDictionary()
for (key, value) in elements {
dict[key] = value
}
@@ -44,7 +44,7 @@ extension CIFilter {
extension CISampler {
// - (id)initWithImage:(CIImage *)im keysAndValues:key0, ...;
convenience init(im: CIImage!, elements: (NSCopying, AnyObject)...) {
var dict = NSMutableDictionary()
let dict = NSMutableDictionary()
for (key, value) in elements {
dict[key] = value
}

View File

@@ -143,7 +143,7 @@ public func XCTAssertNotNil(@autoclosure expression: () -> AnyObject?, _ message
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr as NSString), message, file, line)
}
case .FailedWithException(let className, let name, let reason):
case .FailedWithException(_, _, let reason):
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 1, reason as NSString), message, file, line)
case .FailedWithUnknownException:
@@ -233,7 +233,7 @@ public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () -> T, @au
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -274,7 +274,7 @@ public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () -> ArrayS
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -309,7 +309,7 @@ public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () -> Contig
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -344,7 +344,7 @@ public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () -> [T], @
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -379,7 +379,7 @@ public func XCTAssertEqual<T, U : Equatable>(@autoclosure expression1: () -> [T:
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -414,7 +414,7 @@ public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () -> T,
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -455,7 +455,7 @@ public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () -> Con
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -490,7 +490,7 @@ public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () -> Arr
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -525,7 +525,7 @@ public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () -> [T]
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -560,7 +560,7 @@ public func XCTAssertNotEqual<T, U : Equatable>(@autoclosure expression1: () ->
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -627,9 +627,9 @@ public func XCTAssertEqualWithAccuracy<T : FloatingPointType>(@autoclosure expre
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
var accuracyStr = "\(accuracy)"
let accuracyStr = "\(accuracy)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString, accuracyStr as NSString), message, file, line)
}
@@ -695,9 +695,9 @@ public func XCTAssertNotEqualWithAccuracy<T : FloatingPointType>(@autoclosure ex
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
var accuracyStr = "\(accuracy)"
let accuracyStr = "\(accuracy)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString, accuracyStr as NSString), message, file, line)
}
@@ -731,7 +731,7 @@ public func XCTAssertGreaterThan<T : Comparable>(@autoclosure expression1: () ->
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -767,7 +767,7 @@ public func XCTAssertGreaterThanOrEqual<T : Comparable>(@autoclosure expression1
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -802,7 +802,7 @@ public func XCTAssertLessThan<T : Comparable>(@autoclosure expression1: () -> T,
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)
@@ -838,7 +838,7 @@ public func XCTAssertLessThanOrEqual<T : Comparable>(@autoclosure expression1: (
// TODO: @auto_string expression1
// TODO: @auto_string expression2
var expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr1 = "\(expressionValue1)"
let expressionValueStr2 = "\(expressionValue2)"
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr1 as NSString, expressionValueStr2 as NSString), message, file, line)

View File

@@ -121,7 +121,7 @@ public func split<S: Sliceable, R:BooleanType>(
for j in elements.indices {
if isSeparator(elements[j]) {
if startIndex != nil {
var i = startIndex!
let i = startIndex!
result.append(elements[i..<j])
startIndex = .Some(j.successor())
if ++splits >= maxSplit {
@@ -207,7 +207,7 @@ public struct EnumerateGenerator<
///
/// Requires: no preceding call to `self.next()` has returned `nil`.
public mutating func next() -> Element? {
var b = base.next()
let b = base.next()
if b == nil { return .None }
return .Some((index: count++, element: b!))
}

View File

@@ -233,7 +233,7 @@ extension _ArrayBuffer {
// Make another pass to retain the copied objects
var result = target
for i in subRange {
for _ in subRange {
result.initialize(result.memory)
++result
}
@@ -262,7 +262,7 @@ extension _ArrayBuffer {
}
// No contiguous storage found; we must allocate
var result = _ContiguousArrayBuffer<T>(
let result = _ContiguousArrayBuffer<T>(
count: subRangeCount, minimumCapacity: 0)
// Tell Cocoa to copy the objects into our storage

View File

@@ -148,7 +148,7 @@ internal func _arrayConditionalBridgeElements<SourceElement, TargetElement>(
_sanityCheck(_isBridgedVerbatimToObjectiveC(SourceElement.self))
_sanityCheck(!_isBridgedVerbatimToObjectiveC(TargetElement.self))
var buf = _ContiguousArrayBuffer<TargetElement>(
let buf = _ContiguousArrayBuffer<TargetElement>(
count: source.count, minimumCapacity: 0)
var p = buf.baseAddress

View File

@@ -318,7 +318,7 @@ public struct ${Self}<T>
// path preventing retains/releases to be matched accross that region.
@inline(never)
func _copyBuffer(inout buffer: _Buffer) {
var newBuffer = _ContiguousArrayBuffer<T>(
let newBuffer = _ContiguousArrayBuffer<T>(
count: buffer.count, minimumCapacity: buffer.count)
let target = buffer._uninitializedCopy(
0..<count, target: newBuffer.baseAddress)
@@ -479,7 +479,7 @@ extension ${Self} : _ArrayType {
internal static func _allocateUninitialized(
count: Int
) -> (${Self}, UnsafeMutablePointer<T>) {
var result = ${Self}(_uninitializedCount: count)
let result = ${Self}(_uninitializedCount: count)
return (result, result._buffer.baseAddress)
}
@@ -523,7 +523,7 @@ extension ${Self} : _ArrayType {
public mutating func reserveCapacity(minimumCapacity: Int) {
if _buffer.requestUniqueMutableBackingBuffer(minimumCapacity) == nil {
var newBuffer = _ContiguousArrayBuffer<T>(
let newBuffer = _ContiguousArrayBuffer<T>(
count: count, minimumCapacity: minimumCapacity)
_buffer._uninitializedCopy(0..<count, target: newBuffer.baseAddress)
@@ -1261,7 +1261,7 @@ extension Array {
public init(
_fromCocoaArray source: _NSArrayCoreType,
noCopy: Bool = false) {
var selectedSource: _NSArrayCoreType =
let selectedSource: _NSArrayCoreType =
noCopy ?
source :
unsafeBitCast(

View File

@@ -55,7 +55,7 @@ public func _persistCString(s: UnsafePointer<CChar>) -> [CChar]? {
if s == nil {
return .None
}
var length = Int(strlen(s))
let length = Int(strlen(s))
var result = [CChar](count: length + 1, repeatedValue: 0)
for var i = 0; i < length; ++i {
// FIXME: this will not compile on platforms where 'CChar' is unsigned.

View File

@@ -97,7 +97,7 @@ public struct Character :
s.startIndex.successor() == s.endIndex,
"Can't form a Character from a String containing more than one extended grapheme cluster")
var (count, initialUTF8) = s._core._encodeSomeUTF8(0)
let (count, initialUTF8) = s._core._encodeSomeUTF8(0)
// Notice that the result of sizeof() is a small non-zero number and can't
// overflow when multiplied by 8.
let bits = sizeofValue(initialUTF8) &* 8 &- 1

View File

@@ -312,7 +312,7 @@ public struct PermutationGenerator<
///
/// Requires: no preceding call to `self.next()` has returned `nil`.
public mutating func next() -> Element? {
var result = indices.next()
let result = indices.next()
return result != nil ? seq[result!] : .None
}

View File

@@ -582,7 +582,7 @@ func _copyCollectionToNativeArrayBuffer<
return _ContiguousArrayBuffer()
}
var result = _ContiguousArrayBuffer<C.Generator.Element>(
let result = _ContiguousArrayBuffer<C.Generator.Element>(
count: numericCast(count),
minimumCapacity: 0
)

View File

@@ -614,7 +614,7 @@ public prefix func ++ (inout x: ${Self}) -> ${Self} {
@transparent
public postfix func ++ (inout x: ${Self}) -> ${Self} {
var ret = x
let ret = x
x = x + 1
return ret
}
@@ -627,7 +627,7 @@ public prefix func -- (inout x: ${Self}) -> ${Self} {
@transparent
public postfix func -- (inout x: ${Self}) -> ${Self} {
var ret = x
let ret = x
x = x - 1
return ret
}

View File

@@ -179,7 +179,7 @@ public struct ${Self} {
/// Create an instance initialized to zero.
@transparent public
init() {
var zero: Int64 = 0
let zero: Int64 = 0
value = Builtin.uitofp_Int64_FPIEEE${bits}(zero.value)
}
@@ -224,7 +224,7 @@ extension ${Self} : FloatingPointType {
}
func __getSignificand() -> _BitsType {
var mask: _BitsType = (1 << ${getSignificantBitCount(bits)}) - 1
let mask: _BitsType = (1 << ${getSignificantBitCount(bits)}) - 1
return _toBitPattern() & mask
}
@@ -251,7 +251,7 @@ extension ${Self} : FloatingPointType {
/// `true` iff `self` is normal (not zero, subnormal, infinity, or
/// NaN).
public var isNormal: Bool {
var biasedExponent = __getBiasedExponent()
let biasedExponent = __getBiasedExponent()
return biasedExponent != ${getInfinityExponent(bits)} &&
biasedExponent != 0
}
@@ -265,7 +265,7 @@ extension ${Self} : FloatingPointType {
/// `true` iff `self` is +0.0 or -0.0.
public var isZero: Bool {
// Mask out the sign bit.
var mask: _BitsType = (1 << (${bits} - 1)) - 1
let mask: _BitsType = (1 << (${bits} - 1)) - 1
return (_toBitPattern() & mask) == 0
}
@@ -315,7 +315,7 @@ extension ${Self} : FloatingPointType {
// bit of the trailing significand field is 0, some other bit of the
// trailing significand field must be non-zero to distinguish the NaN
// from infinity.
var significand = __getSignificand()
let significand = __getSignificand()
if significand != 0 {
return (significand >> (${getSignificantBitCount(bits)} - 1)) == 0
}
@@ -329,19 +329,19 @@ extension ${Self} /* : FloatingPointType */ {
/// The IEEE 754 "class" of this type.
public var floatingPointClass: FloatingPointClassification {
get {
var biasedExponent = __getBiasedExponent()
let biasedExponent = __getBiasedExponent()
if biasedExponent == ${getInfinityExponent(bits)} {
var significand = __getSignificand()
let significand = __getSignificand()
// This is either +/-inf or NaN.
if significand == 0 {
return isSignMinus ? .NegativeInfinity : .PositiveInfinity
}
var isQNaN = (significand >> (${getSignificantBitCount(bits)} - 1)) == 1
let isQNaN = (significand >> (${getSignificantBitCount(bits)} - 1)) == 1
return isQNaN ? .QuietNaN : .SignalingNaN
}
// OK, the number is finite.
var isMinus = isSignMinus
let isMinus = isSignMinus
if biasedExponent != 0 {
return isMinus ? .NegativeNormal : .PositiveNormal
}

View File

@@ -583,7 +583,7 @@ public struct Set<T : Hashable> :
//
// FIXME(performance): perform this operation at a lower level
// to avoid invalidating the index and avoiding a copy.
var result = self.intersect(sequence)
let result = self.intersect(sequence)
// The result can only have fewer or the same number of elements.
// If no elements were removed, don't perform a reassignment
@@ -609,7 +609,7 @@ public struct Set<T : Hashable> :
public mutating func exclusiveOrInPlace<
S: SequenceType where S.Generator.Element == T
>(sequence: S) {
var other = sequence as? Set<T> ?? Set(sequence)
let other = sequence as? Set<T> ?? Set(sequence)
for member in other {
if contains(member) {
remove(member)
@@ -677,7 +677,7 @@ public func == <T : Hashable>(lhs: Set<T>, rhs: Set<T>) -> Bool {
}
for member in lhs {
var (pos, found) = rhsNative._find(member, rhsNative._bucket(member))
let (pos, found) = rhsNative._find(member, rhsNative._bucket(member))
if !found {
return false
}
@@ -766,7 +766,7 @@ func _stdlib_CFSetGetValues(nss: _NSSetType, UnsafeMutablePointer<AnyObject>)
internal func _stdlib_NSSet_allObjects(nss: _NSSetType) ->
_HeapBuffer<Int, AnyObject> {
let count = nss.count
var buffer = _HeapBuffer<Int, AnyObject>(
let buffer = _HeapBuffer<Int, AnyObject>(
_HeapBufferStorage<Int, AnyObject>.self, count, count)
_stdlib_CFSetGetValues(nss, buffer.baseAddress)
return buffer
@@ -1198,7 +1198,7 @@ public func == <Key : Equatable, Value : Equatable>(
}
for (k, v) in lhs {
var (pos, found) = rhsNative._find(k, rhsNative._bucket(k))
let (pos, found) = rhsNative._find(k, rhsNative._bucket(k))
// FIXME: Can't write the simple code pending
// <rdar://problem/15484639> Refcounting bug
/*
@@ -1311,7 +1311,7 @@ extension Dictionary : CustomStringConvertible, CustomDebugStringConvertible {
internal func _stdlib_NSDictionary_allKeys(nsd: _NSDictionaryType)
-> _HeapBuffer<Int, AnyObject> {
let count = nsd.count
var buffer = _HeapBuffer<Int, AnyObject>(
let buffer = _HeapBuffer<Int, AnyObject>(
_HeapBufferStorage<Int, AnyObject>.self, count, count)
nsd.getObjects(nil, andKeys: buffer.baseAddress)
@@ -1756,7 +1756,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
// The invariant guarantees there's always a hole, so we just loop
// until we find one
while true {
var keyVal = self[bucket]
let keyVal = self[bucket]
if (keyVal == nil) || keyVal!.key == k {
return (Index(nativeStorage: self, offset: bucket), (keyVal != nil))
}
@@ -1779,7 +1779,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
%if Self == 'Set':
internal mutating func unsafeAddNew(key newKey: T) {
var (i, found) = _find(newKey, _bucket(newKey))
let (i, found) = _find(newKey, _bucket(newKey))
_sanityCheck(
!found, "unsafeAddNew was called, but the key is already present")
self[i.offset] = Element(key: newKey)
@@ -1788,7 +1788,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
%elif Self == 'Dictionary':
internal mutating func unsafeAddNew(key newKey: Key, value: Value) {
var (i, found) = _find(newKey, _bucket(newKey))
let (i, found) = _find(newKey, _bucket(newKey))
_sanityCheck(
!found, "unsafeAddNew was called, but the key is already present")
self[i.offset] = Element(key: newKey, value: value)
@@ -1904,7 +1904,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
var count = 0
for key in elements {
var (i, found) = nativeStorage._find(key, nativeStorage._bucket(key))
let (i, found) = nativeStorage._find(key, nativeStorage._bucket(key))
if found {
continue
}
@@ -1916,7 +1916,7 @@ struct _Native${Self}Storage<${TypeParametersDecl}> :
%elif Self == 'Dictionary':
for (key, value) in elements {
var (i, found) = nativeStorage._find(key, nativeStorage._bucket(key))
let (i, found) = nativeStorage._find(key, nativeStorage._bucket(key))
_precondition(!found, "${Self} literal contains duplicate keys")
nativeStorage[i.offset] = Element(key: key, value: value)
}
@@ -2545,7 +2545,7 @@ final internal class _Native${Self}StorageOwner<${TypeParametersDecl}>
break
}
var bridgedKey: AnyObject = _getBridgedKey(currIndex)
let bridgedKey: AnyObject = _getBridgedKey(currIndex)
unmanagedObjects[i] = bridgedKey
++stored
currIndex = currIndex.successor()
@@ -2780,7 +2780,7 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType {
let cocoa${Self} = cocoaStorage.cocoa${Self}
let newNativeOwner = NativeStorageOwner(minimumCapacity: minimumCapacity)
var newNativeStorage = newNativeOwner.nativeStorage
var oldCocoaGenerator = _Cocoa${Self}Generator(cocoa${Self})
let oldCocoaGenerator = _Cocoa${Self}Generator(cocoa${Self})
%if Self == 'Set':
while let key = oldCocoaGenerator.next() {
newNativeStorage.unsafeAddNew(
@@ -2876,11 +2876,11 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType {
case .Cocoa(let cocoaStorage):
#if _runtime(_ObjC)
%if Self == 'Set':
var anyObjectValue: AnyObject = cocoaStorage.assertingGet(i._cocoaIndex)
let anyObjectValue: AnyObject = cocoaStorage.assertingGet(i._cocoaIndex)
let nativeValue = _forceBridgeFromObjectiveC(anyObjectValue, Value.self)
return nativeValue
%elif Self == 'Dictionary':
var (anyObjectKey, anyObjectValue) =
let (anyObjectKey, anyObjectValue) =
cocoaStorage.assertingGet(i._cocoaIndex)
let nativeKey = _forceBridgeFromObjectiveC(anyObjectKey, Key.self)
let nativeValue = _forceBridgeFromObjectiveC(anyObjectValue, Value.self)
@@ -3007,13 +3007,13 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType {
// something out-of-place.
var b: Int
for b = lastInChain; b != hole; b = nativeStorage._prev(b) {
var idealBucket = nativeStorage._bucket(nativeStorage[b]!.key)
let idealBucket = nativeStorage._bucket(nativeStorage[b]!.key)
// Does this element belong between start and hole? We need
// two separate tests depending on whether [start,hole] wraps
// around the end of the buffer
var c0 = idealBucket >= start
var c1 = idealBucket <= hole
let c0 = idealBucket >= start
let c1 = idealBucket <= hole
if start <= hole ? (c0 && c1) : (c0 || c1) {
break // found it
}
@@ -3063,8 +3063,7 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType {
// The provided index should be valid, so we will always mutating the
// set storage. Request unique storage.
let (reallocated, capacityChanged) =
ensureUniqueNativeStorage(nativeStorage.capacity)
let (reallocated, _) = ensureUniqueNativeStorage(nativeStorage.capacity)
if reallocated {
nativeStorage = native
}
@@ -3134,8 +3133,7 @@ internal enum _Variant${Self}Storage<${TypeParametersDecl}> : _HashStorageType {
// We have already checked for the empty dictionary case, so we will always
// mutating the dictionary storage. Request unique storage.
let (reallocated, capacityChanged) =
ensureUniqueNativeStorage(nativeStorage.capacity)
let (reallocated, _) = ensureUniqueNativeStorage(nativeStorage.capacity)
if reallocated {
nativeStorage = native
}

View File

@@ -145,7 +145,7 @@ public prefix func ++ <T : _Incrementable> (inout i: T) -> T {
/// value of `i`.
@transparent
public postfix func ++ <T : _Incrementable> (inout i: T) -> T {
var ret = i
let ret = i
i._successorInPlace()
return ret
}
@@ -273,7 +273,7 @@ public prefix func -- <T : _BidirectionalIndexType> (inout i: T) -> T {
/// value of `i`.
@transparent
public postfix func -- <T : _BidirectionalIndexType> (inout i: T) -> T {
var ret = i
let ret = i
i._predecessorInPlace()
return ret
}
@@ -386,7 +386,7 @@ public func ~> <T : _RandomAccessIndexType>(
let end = rest.1.1
let d = start.distanceTo(end)
var amount = n
let amount = n
if n < 0 {
if d < 0 && d > n {
return end

View File

@@ -158,7 +158,7 @@ public func join<
// FIXME: include separator
let reservation = elements~>_preprocessingPass {
(s: S) -> C.Index.Distance in
var r: C.Index.Distance = s.reduce(0) { $0 + separatorSize + $1.count() }
let r: C.Index.Distance = s.reduce(0) { $0 + separatorSize + $1.count() }
return r - separatorSize
}

View File

@@ -47,7 +47,7 @@ extension String {
// Fix the lifetime of the given instruction so that the ARC optimizer does not
// shorten the lifetime of x to be before this point.
@transparent
public func _fixLifetime<T>(var x: T) {
public func _fixLifetime<T>(x: T) {
Builtin.fixLifetime(x)
}

View File

@@ -188,7 +188,7 @@ public struct ManagedBufferPointer<Value, Element> : Equatable {
}
// FIXME: workaround for <rdar://problem/18619176>. If we don't
// access value somewhere, its addressor gets linked away
let x = value
_ = value
}
/// Manage the given `buffer`.

View File

@@ -59,7 +59,7 @@ func _isPowerOf2(x: Int) -> Bool {
func _withUninitializedString<R>(
body: (UnsafeMutablePointer<String>) -> R
) -> (R, String) {
var stringPtr = UnsafeMutablePointer<String>.alloc(1)
let stringPtr = UnsafeMutablePointer<String>.alloc(1)
let bodyResult = body(stringPtr)
let stringResult = stringPtr.move()
stringPtr.dealloc(1)
@@ -74,7 +74,7 @@ public func _stdlib_getDemangledMetatypeNameImpl(type: Any.Type, _ result: Unsaf
/// Returns the demangled name of a metatype.
public func _typeName(type: Any.Type) -> String {
var stringPtr = UnsafeMutablePointer<String>.alloc(1)
let stringPtr = UnsafeMutablePointer<String>.alloc(1)
_stdlib_getDemangledMetatypeNameImpl(type, stringPtr)
let result = stringPtr.move()
stringPtr.dealloc(1)
@@ -86,7 +86,7 @@ public func _stdlib_getDemangledTypeName<T>(value: T) -> String {
// FIXME: this code should be using _withUninitializedString, but it leaks
// when called from here.
// <rdar://problem/17892969> Closures in generic context leak their captures?
var stringPtr = UnsafeMutablePointer<String>.alloc(1)
let stringPtr = UnsafeMutablePointer<String>.alloc(1)
_stdlib_getDemangledTypeNameImpl(value, stringPtr)
let stringResult = stringPtr.move()
stringPtr.dealloc(1)
@@ -100,7 +100,7 @@ func _stdlib_demangleNameImpl(
_ demangledName: UnsafeMutablePointer<String>)
public func _stdlib_demangleName(mangledName: String) -> String {
var mangledNameUTF8 = Array(mangledName.utf8)
let mangledNameUTF8 = Array(mangledName.utf8)
return mangledNameUTF8.withUnsafeBufferPointer {
(mangledNameUTF8) in
let (_, demangledName) = _withUninitializedString {

View File

@@ -27,7 +27,7 @@ public enum Optional<T> : Reflectable, NilLiteralConvertible {
/// If `self == nil`, returns `nil`. Otherwise, returns `f(self!)`.
public func map<U>(@noescape f: (T)->U) -> U? {
switch self {
case .Some(var y):
case .Some(let y):
return .Some(f(y))
case .None:
return .None

View File

@@ -94,7 +94,7 @@ public typealias Printable = CustomStringConvertible
internal func _adHocPrint<T, TargetStream : OutputStreamType>(
value: T, inout _ target: TargetStream
) {
var mirror = reflect(value)
let mirror = reflect(value)
// Checking the mirror kind is not a good way to implement this, but we don't
// have a more expressive reflection API now.
if mirror is _TupleMirror {
@@ -106,8 +106,8 @@ internal func _adHocPrint<T, TargetStream : OutputStreamType>(
} else {
target.write(", ")
}
var (label, elementMirror) = mirror[i]
var elt = elementMirror.value
let (label, elementMirror) = mirror[i]
let elt = elementMirror.value
debugPrint(elt, &target, appendNewline: false)
}
target.write(")")
@@ -123,7 +123,7 @@ internal func _adHocPrint<T, TargetStream : OutputStreamType>(
} else {
target.write(", ")
}
var (label, elementMirror) = mirror[i]
let (label, elementMirror) = mirror[i]
print(label, &target, appendNewline: false)
target.write(": ")
debugPrint(elementMirror.value, &target, appendNewline: false)
@@ -143,7 +143,7 @@ internal func _print_unlocked<T, TargetStream : OutputStreamType>(
return
}
if case var printableObject as CustomStringConvertible = value {
if case let printableObject as CustomStringConvertible = value {
printableObject.description.writeTo(&target)
return
}
@@ -188,7 +188,7 @@ public func _debugPrint_unlocked<T, TargetStream : OutputStreamType>(
return
}
if var printableObject = value as? CustomStringConvertible {
if let printableObject = value as? CustomStringConvertible {
printableObject.description.writeTo(&target)
return
}

View File

@@ -360,7 +360,7 @@ public struct _MagicMirrorData {
}
var summary: String {
var (_, result) = _withUninitializedString {
let (_, result) = _withUninitializedString {
_swift_MagicMirrorData_summaryImpl(self.metadata, $0)
}
return result

View File

@@ -400,7 +400,7 @@ func _uint64ToString(
func _rawPointerToString(value: Builtin.RawPointer) -> String {
var result = _uint64ToString(
UInt64(unsafeBitCast(value, UWord.self)), radix: 16, uppercase: false)
for i in 0..<(2 * sizeof(Builtin.RawPointer) - result.count()) {
for _ in 0..<(2 * sizeof(Builtin.RawPointer) - result.count()) {
result = "0" + result
}
return "0x" + result

View File

@@ -174,7 +174,7 @@ struct _SliceBuffer<T> : _ArrayBufferType {
public
func _uninitializedCopy(
subRange: Range<Int>, var target: UnsafeMutablePointer<T>
subRange: Range<Int>, target: UnsafeMutablePointer<T>
) -> UnsafeMutablePointer<T> {
_invariantCheck()
_sanityCheck(subRange.startIndex >= 0)

View File

@@ -57,7 +57,7 @@ func _insertionSort<
// Continue until the sorted elements cover the whole sequence
while (++sortedEnd != range.endIndex) {
// get the first unsorted element
var x: C.Generator.Element = elements[sortedEnd]
let x: C.Generator.Element = elements[sortedEnd]
// Look backwards for x's position in the sorted sequence,
// moving elements forward to make room.
@@ -267,7 +267,7 @@ func _heapSort<
${"inout _ isOrderedBefore: (C.Generator.Element, C.Generator.Element)->Bool" if p else ""}
) {
var hi = range.endIndex
var lo = range.startIndex
let lo = range.startIndex
_heapify(&elements, range ${", &isOrderedBefore" if p else ""})
while --hi != lo {
swap(&elements[lo], &elements[hi])

View File

@@ -786,7 +786,7 @@ extension String {
if self._core.isASCII {
let length = self._core.count
let source = self._core.startASCII
var buffer = _StringBuffer(
let buffer = _StringBuffer(
capacity: length, initialSize: length, elementWidth: 1)
var dest = UnsafeMutablePointer<UInt8>(buffer.start)
for i in 0..<length {
@@ -824,7 +824,7 @@ extension String {
if self._core.isASCII {
let length = self._core.count
let source = self._core.startASCII
var buffer = _StringBuffer(
let buffer = _StringBuffer(
capacity: length, initialSize: length, elementWidth: 1)
var dest = UnsafeMutablePointer<UInt8>(buffer.start)
for i in 0..<length {

View File

@@ -75,10 +75,10 @@ internal func _cocoaStringToContiguous(
_sanityCheck(CFStringGetCharactersPtr(source) == nil,
"Known contiguously-stored strings should already be converted to Swift")
var startIndex = range.startIndex
var count = range.endIndex - startIndex
let startIndex = range.startIndex
let count = range.endIndex - startIndex
var buffer = _StringBuffer(capacity: max(count, minimumCapacity),
let buffer = _StringBuffer(capacity: max(count, minimumCapacity),
initialSize: count, elementWidth: 2)
CFStringGetCharacters(

View File

@@ -90,14 +90,14 @@ public struct _StringBuffer {
minimumCapacity: Int = 0
) -> (_StringBuffer?, hadError: Bool) {
// Determine how many UTF-16 code units we'll need
var inputStream = input.generate()
let inputStream = input.generate()
guard let (utf16Count, isAscii) = UTF16.measure(encoding, input: inputStream,
repairIllFormedSequences: repairIllFormedSequences) else {
return (.None, true)
}
// Allocate storage
var result = _StringBuffer(
let result = _StringBuffer(
capacity: max(utf16Count, minimumCapacity),
initialSize: utf16Count,
elementWidth: isAscii ? 1 : 2)

View File

@@ -160,7 +160,7 @@ extension String.CharacterView : CollectionType {
internal static func _measureExtendedGraphemeClusterBackward(
end: UnicodeScalarView.Index
) -> Int {
var start = end._viewStartIndex
let start = end._viewStartIndex
if start == end {
return 0
}
@@ -277,7 +277,7 @@ extension String.CharacterView : ExtensibleCollectionType {
case .Small(let _63bits):
let bytes = Character._smallValue(_63bits)
_core.extend(Character._SmallUTF16(bytes))
case .Large(let storage):
case .Large(_):
_core.append(String(c)._core)
}
}

View File

@@ -428,7 +428,7 @@ public struct _StringCore {
newSize newSize: Int, newCapacity: Int, minElementWidth: Int
) {
_sanityCheck(newCapacity >= newSize)
var oldCount = count
let oldCount = count
// Allocate storage.
let newElementWidth =
@@ -436,7 +436,7 @@ public struct _StringCore {
? minElementWidth
: representableAsASCII() ? 1 : 2
var newStorage = _StringBuffer(capacity: newCapacity, initialSize: newSize,
let newStorage = _StringBuffer(capacity: newCapacity, initialSize: newSize,
elementWidth: newElementWidth)
if hasContiguousStorage {

View File

@@ -20,7 +20,7 @@ extension String {
capacity: s._core.count * count,
initialSize: 0,
elementWidth: s._core.elementWidth))
for i in 0..<count {
for _ in 0..<count {
self += s
}
}
@@ -37,7 +37,7 @@ extension String {
}
public func _split(separator: UnicodeScalar) -> [String] {
var scalarSlices = Swift.split(unicodeScalars) { $0 == separator }
let scalarSlices = Swift.split(unicodeScalars) { $0 == separator }
return scalarSlices.map { String($0) }
}
@@ -150,7 +150,7 @@ extension String {
func _substr(start: Int) -> String {
var rng = unicodeScalars
var startIndex = rng.startIndex
for i in 0..<start {
for _ in 0..<start {
++startIndex
}
return String(rng[startIndex..<rng.endIndex])
@@ -196,7 +196,7 @@ extension String {
/// the given predicate evaluates true, returning an array of strings that
/// before/between/after those delimiters.
func _splitIf(predicate: (UnicodeScalar) -> Bool) -> [String] {
var scalarSlices = Swift.split(unicodeScalars, isSeparator: predicate)
let scalarSlices = Swift.split(unicodeScalars, isSeparator: predicate)
return scalarSlices.map { String($0) }
}
}

View File

@@ -54,7 +54,7 @@ extension String {
_precondition(position >= 0 && position < _length,
"out-of-range access on a UTF16View")
var index = _toInternalIndex(position)
let index = _toInternalIndex(position)
let u = _core[index]
if _fastPath((u >> 11) != 0b1101_1) {
// Neither high-surrogate, nor low-surrogate -- well-formed sequence

View File

@@ -61,7 +61,7 @@ extension String {
public func successor() -> Index {
var scratch = _ScratchGenerator(_core, _position)
var decoder = UTF16()
let (result, length) = decoder._decodeOne(&scratch)
let (_, length) = decoder._decodeOne(&scratch)
return Index(_position + length, _core)
}

View File

@@ -612,13 +612,13 @@ public struct UTF16 : UnicodeCodecType {
public static func encode<
S : SinkType where S.Element == CodeUnit
>(input: UnicodeScalar, inout output: S) {
var scalarValue: UInt32 = UInt32(input)
let scalarValue: UInt32 = UInt32(input)
if scalarValue <= UInt32(UInt16.max) {
output.put(UInt16(scalarValue))
}
else {
var lead_offset = UInt32(0xd800) - UInt32(0x10000 >> 10)
let lead_offset = UInt32(0xd800) - UInt32(0x10000 >> 10)
output.put(UInt16(lead_offset + (scalarValue >> 10)))
output.put(UInt16(0xdc00 + (scalarValue & 0x3ff)))
}
@@ -760,7 +760,7 @@ internal func _transcodeSomeUTF16AsUTF8<
scalarUtf8Length = 3
}
} else {
var unit0 = u
let unit0 = u
if _slowPath((unit0 >> 10) == 0b1101_11) {
// `unit0` is a low-surrogate. We have an ill-formed sequence.
// Replace it with U+FFFD.

View File

@@ -92,7 +92,7 @@ public struct UnicodeScalar :
/// representation.
public func escape(asASCII forceASCII: Bool) -> String {
func lowNibbleAsHex(v: UInt32) -> String {
var nibble = v & 15
let nibble = v & 15
if nibble < 10 {
return String(UnicodeScalar(nibble+48)) // 48 = '0'
} else {

View File

@@ -104,7 +104,7 @@ public struct ${Self}<T>
///
/// - postcondition: The memory is allocated, but not initialized.
public static func alloc(num: Int) -> ${Self} {
var size = strideof(T.self) * num
let size = strideof(T.self) * num
return ${Self}(
Builtin.allocRaw(size._builtinWordValue, Builtin.alignof(T.self)))
}
@@ -119,7 +119,7 @@ public struct ${Self}<T>
///
/// - postcondition: The memory has been deallocated.
public func dealloc(num: Int) {
var size = strideof(T.self) * num
let size = strideof(T.self) * num
Builtin.deallocRaw(
_rawValue, size._builtinWordValue, Builtin.alignof(T.self))
}

View File

@@ -59,7 +59,7 @@ let _x86_64RegisterSaveWords = _x86_64CountGPRegisters + _x86_64CountSSERegister
/// Invoke `f` with a C `va_list` argument derived from `args`.
public func withVaList<R>(args: [CVarArgType],
@noescape _ f: CVaListPointer -> R) -> R {
var builder = VaListBuilder()
let builder = VaListBuilder()
for a in args {
builder.append(a)
}
@@ -82,7 +82,7 @@ public func withVaList<R>(builder: VaListBuilder,
/// may find that the language rules don't allow you to use
/// `withVaList` as intended.
public func getVaList(args: [CVarArgType]) -> CVaListPointer {
var builder = VaListBuilder()
let builder = VaListBuilder()
for a in args {
builder.append(a)
}
@@ -93,7 +93,7 @@ public func getVaList(args: [CVarArgType]) -> CVaListPointer {
}
public func _encodeBitsAsWords<T : CVarArgType>(x: T) -> [Word] {
var result = [Word](
let result = [Word](
count: (sizeof(T.self) + sizeof(Word.self) - 1) / sizeof(Word.self),
repeatedValue: 0)
var tmp = x