fix PR#76

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3027 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Jacques Garrigue 2000-04-03 02:21:07 +00:00
parent aeabf36020
commit 5aab3937e2
2 changed files with 12 additions and 18 deletions

View File

@ -106,14 +106,10 @@ let find_all db x =
let remove db x = del db x []
let iter f db =
let rec walk k =
let k, v = seq db k [R_NEXT] in
f k v;
walk k
let rec walk = function
None -> ()
| Some(k, v) ->
f k v;
walk (try Some(seq db k [R_NEXT]) with Not_found -> None)
in
try
let k, v = seq db "" [R_FIRST] in
f k v;
walk k
with
Not_found -> ()
walk (try Some(seq db "" [R_FIRST]) with Not_found -> None)

View File

@ -48,12 +48,10 @@ let _ = Callback.register_exception "dbmerror" (Dbm_error "")
(* Usual iterator *)
let iter f t =
let rec walk k =
f k (find t k);
match try Some(nextkey t) with Not_found -> None
with
None -> ()
| Some k -> walk k
let rec walk = function
None -> ()
| Some k ->
f k (find t k);
walk (try Some(nextkey t) with Not_found -> None)
in
walk (firstkey t)
walk (try Some(firstkey t) with Not_found -> None)