Skip to content

Commit

Permalink
put parents sequence right before loop
Browse files Browse the repository at this point in the history
  • Loading branch information
loiclec committed Oct 30, 2016
1 parent 03111dd commit d3a53a4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Sources/Apodimark/InlineParsing/InlineAST.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ fileprivate struct InlineTreeBuilder <View: BidirectionalCollection, RefDef: Ref

mutating func next() -> (Node, DepthLevel)? {

let parents = sequence(state: tryLevel) { [tree] (lvl: inout DepthLevel) -> (NonText, DepthLevel)? in
guard case let .nonText(parent)? = tree.last(depthLevel: lvl.decremented()) else {
return nil
}
defer { lvl = lvl.decremented() }
return (parent, lvl)
}

(e1, e2) = (e1 ?? texts.next(), e2 ?? nonTexts.next())

guard case let (node?, newE1, newE2, insertLevel) = { () -> (Node?, Text?, NonText?, DepthLevel) in
Expand All @@ -69,6 +61,13 @@ fileprivate struct InlineTreeBuilder <View: BidirectionalCollection, RefDef: Ref
}

var insertionLevel = tryLevel
let parents = sequence(state: tryLevel) { [tree] (lvl: inout DepthLevel) -> (NonText, DepthLevel)? in
guard case let .nonText(parent)? = tree.last(depthLevel: lvl.decremented()) else {
return nil
}
defer { lvl = lvl.decremented() }
return (parent, lvl)
}
for (parent, level) in parents {
let parentContent = parent.contentRange(inView: view)

Expand Down

0 comments on commit d3a53a4

Please sign in to comment.