diff options
author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2000-04-03 02:21:07 +0000 |
---|---|---|
committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2000-04-03 02:21:07 +0000 |
commit | 5aab3937e284701521125208408aa24f59f4abfc (patch) | |
tree | 6078a488b76a78b87f5c13eba3f45cbb8a556d28 | |
parent | aeabf3602029fc8f4731b81b18b6eb32d5ed511a (diff) |
fix PR#76
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3027 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | otherlibs/db/db.ml | 16 | ||||
-rw-r--r-- | otherlibs/dbm/dbm.ml | 14 |
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) |