Skip to content

Commit fcb8612

Browse files
committed
Format SingleInlineArray for use in lit tests.
1 parent 778d39d commit fcb8612

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

SwiftCompilerSources/Sources/Basic/Utils.swift

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -114,37 +114,6 @@ public struct StringRef : CustomStringConvertible, NoReflectionChildren {
114114
public static func ~=(pattern: StaticString, value: StringRef) -> Bool { value == pattern }
115115
}
116116

117-
//===----------------------------------------------------------------------===//
118-
// Single-Element Inline Array
119-
//===----------------------------------------------------------------------===//
120-
121-
public struct SingleInlineArray<Element>: RandomAccessCollection {
122-
private var singleElement: Element? = nil
123-
private var multipleElements: [Element] = []
124-
125-
public init() {}
126-
127-
public var startIndex: Int { 0 }
128-
public var endIndex: Int {
129-
singleElement == nil ? 0 : multipleElements.count + 1
130-
}
131-
132-
public subscript(_ index: Int) -> Element {
133-
if index == 0 {
134-
return singleElement!
135-
}
136-
return multipleElements[index - 1]
137-
}
138-
139-
public mutating func push(_ element: Element) {
140-
guard singleElement != nil else {
141-
singleElement = element
142-
return
143-
}
144-
multipleElements.append(element)
145-
}
146-
}
147-
148117
//===----------------------------------------------------------------------===//
149118
// Bridging Utilities
150119
//===----------------------------------------------------------------------===//

SwiftCompilerSources/Sources/SIL/Utilities/SequenceUtilities.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,34 @@ extension LazyMapSequence : CollectionLikeSequence,
117117
extension LazyFilterSequence : CollectionLikeSequence,
118118
FormattedLikeArray, CustomStringConvertible, CustomReflectable
119119
where Base: CollectionLikeSequence {}
120+
121+
//===----------------------------------------------------------------------===//
122+
// Single-Element Inline Array
123+
//===----------------------------------------------------------------------===//
124+
125+
public struct SingleInlineArray<Element>: RandomAccessCollection, FormattedLikeArray {
126+
private var singleElement: Element? = nil
127+
private var multipleElements: [Element] = []
128+
129+
public init() {}
130+
131+
public var startIndex: Int { 0 }
132+
public var endIndex: Int {
133+
singleElement == nil ? 0 : multipleElements.count + 1
134+
}
135+
136+
public subscript(_ index: Int) -> Element {
137+
if index == 0 {
138+
return singleElement!
139+
}
140+
return multipleElements[index - 1]
141+
}
142+
143+
public mutating func push(_ element: Element) {
144+
guard singleElement != nil else {
145+
singleElement = element
146+
return
147+
}
148+
multipleElements.append(element)
149+
}
150+
}

0 commit comments

Comments
 (0)