From c2a88c27fd3867e022c8ae4363bb24bca864619b Mon Sep 17 00:00:00 2001 From: Luc Maranget Date: Fri, 21 Mar 2014 17:02:44 +0000 Subject: #PR6269 Optimized string matching Noticed that I had to bootstrap to test on ARM, so I commit a new bootstrap compiler. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14479 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- bytecomp/printlambda.ml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'bytecomp/printlambda.ml') diff --git a/bytecomp/printlambda.ml b/bytecomp/printlambda.ml index beb268480..e02196f9b 100644 --- a/bytecomp/printlambda.ml +++ b/bytecomp/printlambda.ml @@ -299,11 +299,22 @@ let rec lam ppf = function if !spc then fprintf ppf "@ " else spc := true; fprintf ppf "@[default:@ %a@]" lam l end in - fprintf ppf "@[<1>(%s %a@ @[%a@])@]" (match sw.sw_failaction with None -> "switch*" | _ -> "switch") lam larg switch sw + | Lstringswitch(arg, cases, default) -> + let switch ppf cases = + let spc = ref false in + List.iter + (fun (s, l) -> + if !spc then fprintf ppf "@ " else spc := true; + fprintf ppf "@[case \"%s\":@ %a@]" (String.escaped s) lam l) + cases; + if !spc then fprintf ppf "@ " else spc := true; + fprintf ppf "@[default:@ %a@]" lam default in + fprintf ppf + "@[<1>(stringswitch %a@ @[%a@])@]" lam arg switch cases | Lstaticraise (i, ls) -> let lams ppf largs = List.iter (fun l -> fprintf ppf "@ %a" lam l) largs in -- cgit v1.2.3-70-g09d2