Skip to content

Commit 1585b70

Browse files
committed
Runtime: don't change the shape of bytes when converting to string
1 parent 31317ca commit 1585b70

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

runtime/js/mlBytes.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,18 @@ function caml_string_lessthan(s1, s2) {
742742

743743
//Provides: caml_string_of_bytes
744744
//Requires: caml_convert_string_to_bytes, caml_string_of_jsbytes
745+
//Requires: caml_subarray_to_jsbytes
745746
//If: js-string
746747
function caml_string_of_bytes(s) {
747-
s.t & 6 && caml_convert_string_to_bytes(s);
748-
return caml_string_of_jsbytes(s.c);
748+
switch (s.t & 6) {
749+
case 0 /* BYTES */:
750+
return caml_string_of_jsbytes(s.c);
751+
case 2 /* PARTIAL */:
752+
caml_convert_string_to_bytes(s);
753+
return caml_string_of_jsbytes(s.c);
754+
case 4 /* ARRAY */:
755+
return caml_subarray_to_jsbytes(s.c, 0, s.c.length);
756+
}
749757
}
750758

751759
//Provides: caml_bytes_of_string const

0 commit comments

Comments
 (0)