Skip to content

Commit 2b1a2c4

Browse files
authored
flambda-backend: Stop using exceptions for control flow in camlinternalOO (#2691)
* Stop using exceptions for control flow in camlinternalOO * @lthls review comment
1 parent a9c21bf commit 2b1a2c4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

stdlib/camlinternalOO.ml

+9-5
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ let set_method table label element =
200200
table.hidden_meths <- (label, element) :: table.hidden_meths
201201

202202
let get_method table label =
203-
try List.assoc label table.hidden_meths
204-
with Not_found -> table.methods.(label)
203+
match List.assoc_opt label table.hidden_meths with
204+
| Some x -> x
205+
| None -> table.methods.(label)
205206

206207
let to_list arr =
207208
if arr == Obj.magic 0 then [] else Array.to_list arr
@@ -228,7 +229,9 @@ let narrow table vars virt_meths concr_meths =
228229
by_name := Meths.add met label !by_name;
229230
by_label :=
230231
Labs.add label
231-
(try Labs.find label table.methods_by_label with Not_found -> true)
232+
(match Labs.find_opt label table.methods_by_label with
233+
| Some x -> x
234+
| None -> true)
232235
!by_label)
233236
concr_meths concr_meth_labs;
234237
List.iter2
@@ -269,8 +272,9 @@ let new_slot table =
269272
index
270273

271274
let new_variable table name =
272-
try Vars.find name table.vars
273-
with Not_found ->
275+
match Vars.find_opt name table.vars with
276+
| Some x -> x
277+
| None ->
274278
let index = new_slot table in
275279
if name <> "" then table.vars <- Vars.add name index table.vars;
276280
index

0 commit comments

Comments
 (0)