mirror of
https://github.com/qvacua/vimr.git
synced 2024-09-11 17:15:34 +03:00
Refactor slightly
This commit is contained in:
parent
63f7d65084
commit
ca7a270f52
@ -54,13 +54,8 @@ public extension RandomAccessCollection where Index == Int {
|
||||
func groupedRanges<T: Equatable>(
|
||||
with marker: (Index, Element) -> T
|
||||
) -> [CountableClosedRange<Index>] {
|
||||
if self.isEmpty {
|
||||
return []
|
||||
}
|
||||
|
||||
if self.count == 1 {
|
||||
return [self.startIndex...self.startIndex]
|
||||
}
|
||||
if self.isEmpty { return [] }
|
||||
if self.count == 1 { return [self.startIndex...self.startIndex] }
|
||||
|
||||
var result = [CountableClosedRange<Index>]()
|
||||
result.reserveCapacity(self.count / 2)
|
||||
@ -70,8 +65,6 @@ public extension RandomAccessCollection where Index == Int {
|
||||
var lastEndIndex = self.startIndex
|
||||
var lastMarker = marker(0, self.first!) // self is not empty!
|
||||
for i in self.startIndex..<self.endIndex {
|
||||
defer { lastEndIndex = i }
|
||||
|
||||
let currentMarker = marker(i, self[i])
|
||||
|
||||
if lastMarker == currentMarker {
|
||||
@ -87,6 +80,8 @@ public extension RandomAccessCollection where Index == Int {
|
||||
result.append(i...i)
|
||||
}
|
||||
}
|
||||
|
||||
lastEndIndex = i
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -57,6 +57,16 @@
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "4BEBA5041CFF374B00673FDF"
|
||||
BuildableName = "VimR.app"
|
||||
BlueprintName = "VimR"
|
||||
ReferencedContainer = "container:VimR.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
|
Loading…
Reference in New Issue
Block a user