Skip to content

Commit

Permalink
Runtime: don't change the shape of bytes when converting to string
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Oct 13, 2024
1 parent 95dafb1 commit 272bd75
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions runtime/mlBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,10 +752,18 @@ function caml_string_lessthan(s1, s2) {

//Provides: caml_string_of_bytes
//Requires: caml_convert_string_to_bytes, caml_string_of_jsbytes
//Requires: caml_subarray_to_jsbytes
//If: js-string
function caml_string_of_bytes(s) {
s.t & 6 && caml_convert_string_to_bytes(s);
return caml_string_of_jsbytes(s.c);
switch (s.t & 6) {
case 0 /* BYTES */:
return caml_string_of_jsbytes(s.c);
case 2 /* PARTIAL */:
caml_convert_string_to_bytes(s);
return caml_string_of_jsbytes(s.c);
case 4 /* ARRAY */:
return caml_subarray_to_jsbytes(s.c, 0, s.c.length);
}
}

//Provides: caml_bytes_of_string const
Expand Down

0 comments on commit 272bd75

Please sign in to comment.