reduce indentation level in MakeDfaLoop functors a bit, by performing 'strIdx = ...' calculation before we branch in case expression

This commit is contained in:
2025-07-20 13:48:14 +01:00
parent f57af737b9
commit c6f4d1d8f3

View File

@@ -9,23 +9,22 @@ struct
fun next (lineGap: LineGap.t, cursorIdx) = fun next (lineGap: LineGap.t, cursorIdx) =
let let
val {rightStrings, idx = bufferIdx, ...} = lineGap val {rightStrings, idx = bufferIdx, ...} = lineGap
(* convert absolute cursorIdx to idx relative to hd string *)
val strIdx = cursorIdx - bufferIdx
in in
case rightStrings of case rightStrings of
shd :: stl => shd :: stl =>
let if strIdx < String.size shd then
(* convert absolute cursorIdx to idx relative to hd string *) (* strIdx is in this string *)
val strIdx = cursorIdx - bufferIdx M.fStart (strIdx, cursorIdx, shd, stl, M.startState, 1)
in else
if strIdx < String.size shd then (* strIdx is in tl *)
(* strIdx is in this string *) (case stl of
M.fStart (strIdx, cursorIdx, shd, stl, M.startState, 1) stlhd :: stltl =>
else let val strIdx = strIdx - String.size shd
(* strIdx is in tl *) in M.fStart (strIdx, cursorIdx, stlhd, stltl, M.startState, 1)
case stl of end
stlhd :: stltl => | _ => cursorIdx)
M.fStart (strIdx, cursorIdx, stlhd, stltl, M.startState, 1)
| _ => cursorIdx
end
| [] => cursorIdx | [] => cursorIdx
end end
end end
@@ -35,29 +34,26 @@ struct
fun prev (lineGap: LineGap.t, cursorIdx) = fun prev (lineGap: LineGap.t, cursorIdx) =
let let
val {rightStrings, leftStrings, idx = bufferIdx, ...} = lineGap val {rightStrings, leftStrings, idx = bufferIdx, ...} = lineGap
(* convert absolute cursorIdx to idx relative to hd string *)
val strIdx = cursorIdx - bufferIdx
in in
case rightStrings of case rightStrings of
shd :: stl => shd :: stl =>
let if strIdx < String.size shd then
(* convert absolute cursorIdx to idx relative to hd string *) (* strIdx is in this string *)
val strIdx = cursorIdx - bufferIdx M.fStart (strIdx, cursorIdx, shd, leftStrings, M.startState, 1)
in else
if strIdx < String.size shd then (* strIdx is in tl *)
(* strIdx is in this string *) (case stl of
M.fStart (strIdx, cursorIdx, shd, leftStrings, M.startState, 1) stlhd :: stltl =>
else let
(* strIdx is in tl *) val strIdx = strIdx - String.size shd
(case stl of val leftStrings = shd :: leftStrings
stlhd :: stltl => in
let M.fStart
val strIdx = strIdx - String.size shd (strIdx, cursorIdx, stlhd, leftStrings, M.startState, 1)
val leftStrings = shd :: leftStrings end
in | [] => cursorIdx)
M.fStart
(strIdx, cursorIdx, stlhd, leftStrings, M.startState, 1)
end
| [] => cursorIdx)
end
| [] => cursorIdx | [] => cursorIdx
end end
end end