1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-09-11 17:15:34 +03:00

Refactor slightly

This commit is contained in:
Tae Won Ha 2021-12-23 20:42:37 +01:00
parent 63f7d65084
commit ca7a270f52
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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">