@@ -21,9 +21,9 @@ let raise_errorf t fmt =
2121 Alternativly, we need to wrap records into yet another level *)
2222let rec element_to_map m = function
2323 | (Xml. Element(name , _ , _ ) as x ) :: xs ->
24- let m = StringMap. update name ( function None -> Some [x]
25- | Some xs -> Some (x :: xs))
26- m
24+ let m =
25+ let ks = try StringMap. find name m with Not_found -> [] in
26+ StringMap. add name (x :: ks) m
2727 in
2828 element_to_map m xs
2929 | _ :: xs -> element_to_map m xs
@@ -53,11 +53,7 @@ let to_record: type a b. (t, a, b) structure -> a -> t -> b = fun spec ->
5353 | Cons ((field , to_value_func ), xs ) ->
5454 let cont = inner xs in
5555 fun constr t ->
56- let values =
57- StringMap. find_opt field t
58- |> (function Some xs -> xs | None -> [] )
59- |> List. rev
60- in
56+ let values = try StringMap. find field t |> List. rev with Not_found -> [] in
6157 let arg = match values with
6258 | [ Xml. Element (name, _, xs) ] -> Xml. Element (name, [" record" , " unwrapped" ], xs)
6359 | [ Xml. PCData _ as d ] -> d
@@ -165,8 +161,8 @@ let of_int32 = of_value Int32.to_string
165161let to_int64 = to_value " int64" Int64. of_string
166162let of_int64 = of_value Int64. to_string
167163
168- let to_float = to_value " float" Float. of_string
169- let of_float = of_value Float. to_string
164+ let to_float = to_value " float" float_of_string
165+ let of_float = of_value string_of_float
170166
171167let to_string = to_value " string" (fun x -> x)
172168let of_string = of_value (fun x -> x)
0 commit comments