Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: do not force array shape for bytes in lexing.js #1713

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions runtime/lexing.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ function caml_lex_array(s) {
}

//Provides: caml_lex_engine
//Requires: caml_failwith, caml_lex_array, caml_uint8_array_of_bytes
//Requires: caml_failwith, caml_lex_array
//Requires: caml_bytes_unsafe_get
function caml_lex_engine(tbl, start_state, lexbuf) {
var lex_buffer = 2;
var lex_buffer_len = 3;
Expand All @@ -53,7 +54,7 @@ function caml_lex_engine(tbl, start_state, lexbuf) {
var c,
state = start_state;

var buffer = caml_uint8_array_of_bytes(lexbuf[lex_buffer]);
var buffer = lexbuf[lex_buffer];

if (state >= 0) {
/* First entry */
Expand All @@ -79,7 +80,7 @@ function caml_lex_engine(tbl, start_state, lexbuf) {
else c = 256;
} else {
/* Read next input char */
c = buffer[lexbuf[lex_curr_pos]];
c = caml_bytes_unsafe_get(buffer, lexbuf[lex_curr_pos]);
lexbuf[lex_curr_pos]++;
}
/* Determine next state */
Expand All @@ -105,7 +106,8 @@ function caml_lex_engine(tbl, start_state, lexbuf) {

//Provides: caml_new_lex_engine
//Requires: caml_failwith, caml_lex_array
//Requires: caml_jsbytes_of_string, caml_uint8_array_of_bytes
//Requires: caml_jsbytes_of_string
//Requires: caml_bytes_unsafe_get
function caml_lex_run_mem(s, i, mem, curr_pos) {
for (;;) {
var dst = s.charCodeAt(i);
Expand Down Expand Up @@ -171,7 +173,7 @@ function caml_new_lex_engine(tbl, start_state, lexbuf) {
var c,
state = start_state;

var buffer = caml_uint8_array_of_bytes(lexbuf[lex_buffer]);
var buffer = lexbuf[lex_buffer];

if (state >= 0) {
/* First entry */
Expand Down Expand Up @@ -203,7 +205,7 @@ function caml_new_lex_engine(tbl, start_state, lexbuf) {
else c = 256;
} else {
/* Read next input char */
c = buffer[lexbuf[lex_curr_pos]];
c = caml_bytes_unsafe_get(buffer, lexbuf[lex_curr_pos]);
lexbuf[lex_curr_pos]++;
}
/* Determine next state */
Expand Down
1 change: 0 additions & 1 deletion runtime/mlBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ function caml_uint8_array_of_bytes(s) {
}

//Provides: caml_uint8_array_of_string mutable
//Requires: caml_convert_bytes_to_array
//Requires: caml_ml_string_length, caml_string_unsafe_get
function caml_uint8_array_of_string(s) {
var l = caml_ml_string_length(s);
Expand Down
Loading