File tree Expand file tree Collapse file tree 2 files changed +23
-20
lines changed Expand file tree Collapse file tree 2 files changed +23
-20
lines changed Original file line number Diff line number Diff line change @@ -848,10 +848,11 @@ module Queues = struct
848848
849849 let get tag qs =
850850 with_lock qs.m (fun () ->
851- if StringMap. mem tag qs.qs then
852- StringMap. find tag qs.qs
853- else
854- Queue. create ()
851+ match StringMap. find_opt tag qs.qs with
852+ | Some x ->
853+ x
854+ | None ->
855+ Queue. create ()
855856 )
856857
857858 let tags qs =
@@ -862,10 +863,11 @@ module Queues = struct
862863 let push_with_coalesce should_keep tag item qs =
863864 with_lock qs.m (fun () ->
864865 let q =
865- if StringMap. mem tag qs.qs then
866- StringMap. find tag qs.qs
867- else
868- Queue. create ()
866+ match StringMap. find_opt tag qs.qs with
867+ | Some x ->
868+ x
869+ | None ->
870+ Queue. create ()
869871 in
870872 push_with_coalesce should_keep item q ;
871873 qs.qs < - StringMap. add tag q qs.qs ;
Original file line number Diff line number Diff line change @@ -227,11 +227,13 @@ module MemFS = struct
227227 match (path, fs) with
228228 | [] , Dir d ->
229229 d
230- | p :: ps , Dir d ->
231- if StringMap. mem p ! d then
232- aux ps (StringMap. find p ! d)
233- else
230+ | p :: ps , Dir d -> (
231+ match StringMap. find_opt p ! d with
232+ | Some x ->
233+ aux ps x
234+ | None ->
234235 raise Not_dir
236+ )
235237 | _ , Leaf _ ->
236238 raise Not_dir
237239 in
@@ -285,14 +287,13 @@ module MemFS = struct
285287 (fun p ->
286288 let dir = dir_locked (dirname p) in
287289 let deletable =
288- if StringMap. mem (filename p) ! dir then
289- match StringMap. find (filename p) ! dir with
290- | Dir child ->
291- StringMap. is_empty ! child
292- | Leaf _ ->
293- true
294- else
295- false
290+ match StringMap. find_opt (filename p) ! dir with
291+ | Some (Dir child ) ->
292+ StringMap. is_empty ! child
293+ | Some (Leaf _ ) ->
294+ true
295+ | None ->
296+ false
296297 in
297298 if deletable then dir := StringMap. remove (filename p) ! dir
298299 )
You can’t perform that action at this time.
0 commit comments