Skip to content

Commit 6b0b8c3

Browse files
committed
review: simpler format_text breaks computation
1 parent 55a825d commit 6b0b8c3

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

stdlib/format.ml

+6-9
Original file line numberDiff line numberDiff line change
@@ -1378,15 +1378,12 @@ let format_text fmt6 =
13781378
| Some sep ->
13791379
let before = String.sub s pos (sep-pos) in
13801380
let pos, spaces, newlines = skip_and_count_whites 0 0 len s sep in
1381-
match newlines, spaces with
1382-
| (0|1), spaces ->
1383-
let break = Break("", max spaces 1, 0) in
1384-
String_literal(before, cons ~repeat:1 break len s pos fmt)
1385-
| bl, _ ->
1386-
String_literal(
1387-
before,
1388-
cons ~repeat:bl Force_newline len s pos fmt
1389-
)
1381+
let repeat, break =
1382+
match newlines, spaces with
1383+
| (0|1), spaces -> 1, Break("", max spaces 1, 0)
1384+
| bl, _ -> bl, Force_newline
1385+
in
1386+
String_literal(before, cons ~repeat break len s pos fmt)
13901387
and[@tail_mod_cons] cons ~repeat break len s pos fmt =
13911388
if repeat = 0 then
13921389
split len s pos fmt

0 commit comments

Comments
 (0)