mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Factor out the Diagonal construction.
This commit is contained in:
parent
9b916d3619
commit
3ed7e1da53
@ -84,24 +84,24 @@ runSES eq (EditGraph as bs)
|
|||||||
-- | Move onto a given diagonal from one of its in-bounds adjacent diagonals (if any), and slide down any diagonal edges eagerly.
|
-- | Move onto a given diagonal from one of its in-bounds adjacent diagonals (if any), and slide down any diagonal edges eagerly.
|
||||||
moveFromAdjacent (Distance d) (Diagonal k) = do
|
moveFromAdjacent (Distance d) (Diagonal k) = do
|
||||||
v <- get
|
v <- get
|
||||||
let getK k = let (x, script) = v ! k in Endpoint x (x - unDiagonal k) script
|
let getK k = let (x, script) = v ! Diagonal k in Endpoint x (x - k) script
|
||||||
let endpoint@(Endpoint x' _ script) = slideFrom $! if d == 0 || k < negate m || k > n then
|
let endpoint@(Endpoint x' _ script) = slideFrom $! if d == 0 || k < negate m || k > n then
|
||||||
-- The top-left corner, or otherwise out-of-bounds.
|
-- The top-left corner, or otherwise out-of-bounds.
|
||||||
Endpoint 0 0 []
|
Endpoint 0 0 []
|
||||||
else if k == negate d || k == negate m then
|
else if k == negate d || k == negate m then
|
||||||
-- The lower/left extent of the search region or edit graph, whichever is smaller.
|
-- The lower/left extent of the search region or edit graph, whichever is smaller.
|
||||||
moveDownFrom (getK (Diagonal (succ k)))
|
moveDownFrom (getK (succ k))
|
||||||
else if k /= d && k /= n then do
|
else if k /= d && k /= n then do
|
||||||
-- Somewhere in the interior of the search region and edit graph.
|
-- Somewhere in the interior of the search region and edit graph.
|
||||||
let prev = getK (Diagonal (pred k))
|
let prev = getK (pred k)
|
||||||
let next = getK (Diagonal (succ k))
|
let next = getK (succ k)
|
||||||
if x prev < x next then
|
if x prev < x next then
|
||||||
moveDownFrom next
|
moveDownFrom next
|
||||||
else
|
else
|
||||||
moveRightFrom prev
|
moveRightFrom prev
|
||||||
else
|
else
|
||||||
-- The upper/right extent of the search region or edit graph, whichever is smaller.
|
-- The upper/right extent of the search region or edit graph, whichever is smaller.
|
||||||
moveRightFrom (getK (Diagonal (pred k)))
|
moveRightFrom (getK (pred k))
|
||||||
put (v Array.// [(Diagonal k, (x', script))])
|
put (v Array.// [(Diagonal k, (x', script))])
|
||||||
return endpoint
|
return endpoint
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user