summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--otherlibs/db/db.ml16
-rw-r--r--otherlibs/dbm/dbm.ml14
2 files changed, 12 insertions, 18 deletions
diff --git a/otherlibs/db/db.ml b/otherlibs/db/db.ml
index c1f0428ef..b3d9b1db1 100644
--- a/otherlibs/db/db.ml
+++ b/otherlibs/db/db.ml
@@ -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)
diff --git a/otherlibs/dbm/dbm.ml b/otherlibs/dbm/dbm.ml
index abfabf6ee..916685400 100644
--- a/otherlibs/dbm/dbm.ml
+++ b/otherlibs/dbm/dbm.ml
@@ -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)