Skip to content

Commit 59f3462

Browse files
committed
Optimized JavaScript property accesses when using an OCaml string as a key
The OCaml string is converted to a JavaScript string at compile time. This make us generate better code for the functions `Ojs.{get,set,delete}_prop_ascii` from gen_js_api.
1 parent 416dfd2 commit 59f3462

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

compiler/lib/flow.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ let the_string_of ~target info x =
410410
let the_native_string_of ~target info x =
411411
match the_const_of ~target info x with
412412
| Some (NativeString i) -> Some i
413+
| Some (String i) -> Some (Native_string.of_bytestring i)
413414
| _ -> None
414415

415416
let the_block_contents_of info x =

0 commit comments

Comments
 (0)