Skip to content

[gardening] spacing on properties and arguments in IndexSet (stdlib) #6569

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
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
58 changes: 29 additions & 29 deletions stdlib/public/SDK/Foundation/IndexSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
/// then calling `next()` on this view's iterator will produce 3 ranges before returning nil.
public struct RangeView : Equatable, BidirectionalCollection {
public typealias Index = Int
public let startIndex : Index
public let endIndex : Index
public let startIndex: Index
public let endIndex: Index

fileprivate var indexSet : IndexSet
fileprivate var indexSet: IndexSet

// Range of element values
private var intersectingRange : Range<IndexSet.Element>?
Expand Down Expand Up @@ -170,10 +170,10 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio

/// The mechanism for accessing the integers stored in an IndexSet.
public struct Index : CustomStringConvertible, Comparable {
fileprivate var value : IndexSet.Element
fileprivate var extent : Range<IndexSet.Element>
fileprivate var rangeIndex : Int
fileprivate let rangeCount : Int
fileprivate var value: IndexSet.Element
fileprivate var extent: Range<IndexSet.Element>
fileprivate var rangeIndex: Int
fileprivate let rangeCount: Int

fileprivate init(value: Int, extent: Range<Int>, rangeIndex: Int, rangeCount: Int) {
self.value = value
Expand Down Expand Up @@ -214,7 +214,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
_handle = _MutablePairHandle(NSIndexSet(), copying: false)
}

public var hashValue : Int {
public var hashValue: Int {
return _handle.map { $0.hash }
}

Expand All @@ -230,7 +230,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
/// Returns a `Range`-based view of the entire contents of `self`.
///
/// - seealso: rangeView(of:)
public var rangeView : RangeView {
public var rangeView: RangeView {
return RangeView(indexSet: self, intersecting: nil)
}

Expand Down Expand Up @@ -268,8 +268,8 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio

private func _range(at index: RangeView.Index) -> Range<Element> {
return _handle.map {
var location : UInt = 0
var length : UInt = 0
var location: UInt = 0
var length: UInt = 0
__NSIndexSetRangeAtIndex($0, UInt(index), &location, &length)
return Int(location)..<Int(location)+Int(length)
}
Expand All @@ -290,8 +290,8 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
public var endIndex: Index {
let rangeCount = _rangeCount
let rangeIndex = rangeCount - 1
let extent : Range<Int>
let value : Int
let extent: Range<Int>
let value: Int
if rangeCount > 0 {
extent = _range(at: rangeCount - 1)
value = extent.upperBound // "1 past the end" position is the last range, 1 + the end of that range's extent
Expand Down Expand Up @@ -683,7 +683,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
public func filteredIndexSet(in range : Range<Element>, includeInteger: (Element) throws -> Bool) rethrows -> IndexSet {
let r : NSRange = _toNSRange(range)
return try _handle.map {
var error : Error?
var error: Error?
let result = $0.indexes(in: r, options: [], passingTest: { (i, stop) -> Bool in
do {
let include = try includeInteger(i)
Expand Down Expand Up @@ -794,14 +794,14 @@ extension IndexSet : CustomStringConvertible, CustomDebugStringConvertible, Cust
private struct IndexSetBoundaryIterator : IteratorProtocol {
typealias Element = IndexSet.Element

private var i1 : IndexSet.RangeView.Iterator
private var i2 : IndexSet.RangeView.Iterator
private var i1Range : CountableRange<Element>?
private var i2Range : CountableRange<Element>?
private var i1UsedLower : Bool
private var i2UsedLower : Bool
private var i1: IndexSet.RangeView.Iterator
private var i2: IndexSet.RangeView.Iterator
private var i1Range: CountableRange<Element>?
private var i2Range: CountableRange<Element>?
private var i1UsedLower: Bool
private var i2UsedLower: Bool

fileprivate init(_ is1 : IndexSet, _ is2 : IndexSet) {
fileprivate init(_ is1: IndexSet, _ is2: IndexSet) {
i1 = is1.rangeView.makeIterator()
i2 = is2.rangeView.makeIterator()

Expand All @@ -818,21 +818,21 @@ private struct IndexSetBoundaryIterator : IteratorProtocol {
return nil
}

let nextIn1 : Element
let nextIn1: Element
if let r = i1Range {
nextIn1 = i1UsedLower ? r.upperBound : r.lowerBound
} else {
nextIn1 = Int.max
}

let nextIn2 : Element
let nextIn2: Element
if let r = i2Range {
nextIn2 = i2UsedLower ? r.upperBound : r.lowerBound
} else {
nextIn2 = Int.max
}

var result : Element
var result: Element
if nextIn1 <= nextIn2 {
// 1 has the next element, or they are the same.
result = nextIn1
Expand Down Expand Up @@ -860,7 +860,7 @@ extension IndexSet {
}
}

private func _toNSRange(_ r : Range<IndexSet.Element>) -> NSRange {
private func _toNSRange(_ r: Range<IndexSet.Element>) -> NSRange {
return NSMakeRange(r.lowerBound, r.upperBound - r.lowerBound)
}

Expand Down Expand Up @@ -928,7 +928,7 @@ private final class _MutablePairHandle<ImmutableType : NSObject, MutableType : N
///
/// - parameter immutable: The thing to stash.
/// - parameter copying: Should be true unless you just created the instance (or called copy) and want to transfer ownership to this handle.
init(_ immutable : ImmutableType, copying : Bool = true) {
init(_ immutable: ImmutableType, copying: Bool = true) {
if copying {
self._pointer = _MutablePair.Default(immutable.copy() as! ImmutableType)
} else {
Expand All @@ -940,7 +940,7 @@ private final class _MutablePairHandle<ImmutableType : NSObject, MutableType : N
///
/// - parameter mutable: The thing to stash.
/// - parameter copying: Should be true unless you just created the instance (or called copy) and want to transfer ownership to this handle.
init(_ mutable : MutableType, copying : Bool = true) {
init(_ mutable: MutableType, copying: Bool = true) {
if copying {
self._pointer = _MutablePair.Mutable(mutable.mutableCopy() as! MutableType)
} else {
Expand All @@ -950,7 +950,7 @@ private final class _MutablePairHandle<ImmutableType : NSObject, MutableType : N

/// Apply a closure to the reference type, regardless if it is mutable or immutable.
@inline(__always)
func map<ReturnType>(_ whatToDo : (ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
func map<ReturnType>(_ whatToDo: (ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
switch _pointer {
case .Default(let i):
return try whatToDo(i)
Expand All @@ -960,7 +960,7 @@ private final class _MutablePairHandle<ImmutableType : NSObject, MutableType : N
}
}

var reference : ImmutableType {
var reference: ImmutableType {
switch _pointer {
case .Default(let i):
return i
Expand Down