1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00

Factor out the bindings of prev & next.

This commit is contained in:
Rob Rix 2017-06-13 21:19:23 -04:00
parent 2078aca839
commit 4f79384094

View File

@ -73,23 +73,23 @@ runSES eq (EditGraph as bs)
searchAlongK (Diagonal k) = do
v <- get
let getK = uncurry Endpoint . (v !) . Diagonal
let Endpoint x' script = slideFrom $! if d == 0 || k < negate m || k > n then
prev = getK (pred k)
next = getK (succ k)
Endpoint x' script = slideFrom $! if d == 0 || k < negate m || k > n then
-- The top-left corner, or otherwise out-of-bounds.
Endpoint 0 []
else if k == negate d || k == negate m then
-- The lower/left extent of the search region or edit graph, whichever is smaller.
moveDownFrom (getK (succ k))
moveDownFrom next
else if k /= d && k /= n then
-- Somewhere in the interior of the search region and edit graph.
let prev = getK (pred k)
next = getK (succ k) in
if x prev < x next then
moveDownFrom next
else
moveRightFrom prev
else
-- The upper/right extent of the search region or edit graph, whichever is smaller.
moveRightFrom (getK (pred k))
moveRightFrom prev
put (v Array.// [(Diagonal k, (x', script))])
return $! if x' >= n && (x' - k) >= m then
Just (script, d)