Skip to content

Commit

Permalink
Rewrite match with if/else
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg committed Mar 30, 2021
1 parent ab04fb0 commit 1dcc317
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions otherlibs/stdune-unstable/ansi_color.ml
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,16 @@ let parse_line str styles =
String.sub str ~pos:seq_start ~len:(seq_end - seq_start)
|> String.split ~on:';'
|> List.fold_left ~init:(List.rev styles) ~f:(fun styles s ->
match s with
| "39" ->
if s = Style.fg_default then
List.filter styles ~f:(fun s ->
not (List.mem Style.fg_all s ~equal:String.equal))
| "49" ->
else if s = Style.bg_default then
List.filter styles ~f:(fun s ->
not (List.mem Style.bg_all s ~equal:String.equal))
| "0" -> []
| _ -> s :: styles)
else if s = "0" then
[]
else
s :: styles)
|> List.rev
in
loop styles (seq_end + 1) acc)
Expand Down

0 comments on commit 1dcc317

Please sign in to comment.