1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Extract a common handler for producing a result from a search.

This commit is contained in:
Rob Rix 2017-03-13 15:13:31 -04:00
parent 2d7bdeff56
commit 7e02b60c3b

View File

@ -122,7 +122,7 @@ decompose myers = let ?callStack = popCallStack callStack in case myers of
backwardV <- gets backward
let reverseEndpoint = let x = backwardV `at` k in Endpoint x (x - k)
if odd delta && k `inInterval` (delta - pred d, delta + pred d) && overlaps graph forwardEndpoint reverseEndpoint then
return (Just (Snake (Endpoint (n - x reverseEndpoint) (m - y reverseEndpoint)) forwardEndpoint, EditDistance $ 2 * d - 1))
return (done reverseEndpoint forwardEndpoint (2 * d - 1))
else
continue
@ -131,7 +131,7 @@ decompose myers = let ?callStack = popCallStack callStack in case myers of
forwardV <- gets forward
let forwardEndpoint = let x = forwardV `at` (k + delta) in Endpoint x (x - k)
if even delta && (k + delta) `inInterval` (negate d, d) && overlaps graph forwardEndpoint reverseEndpoint then
return (Just (Snake (Endpoint (n - x reverseEndpoint) (m - y reverseEndpoint)) forwardEndpoint, EditDistance $ 2 * d))
return (done reverseEndpoint forwardEndpoint (2 * d))
else
continue
@ -168,6 +168,8 @@ decompose myers = let ?callStack = popCallStack callStack in case myers of
at v k = v ! maxD + k
done (Endpoint x y) uv d = Just (Snake (Endpoint (n - x) (m - y)) uv, EditDistance d)
slide dir eq (Endpoint x y)
| x >= 0, x < length as
, y >= 0, y < length bs