My working unpac space for OCaml projects in development
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Sprint 1.4: Add fast path for typed array element access

Extended the integer index fast path to typed array operations:

- Added fast path for Int/Float indices in typed array get
- Added fast path for Int/Float indices in typed array set
- Matches the pattern used for regular array access

The typed array length was already cached in the Data_typed_array
record, so no additional caching was needed there.

Tests: 176/176 runtime tests passing, 52,631/52,631 Test262 passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+12 -2
+12 -2
lib/quickjs/runtime/interpreter.ml
··· 295 295 if idx >= 0 && idx < arr_data.length then arr_data.values.(idx) 296 296 else Undefined 297 297 | Object ({ data = Data_typed_array { buffer; byte_offset; length }; class_id; _ }) -> 298 - let idx = Int32.to_int (to_int32 index) in 298 + (* Fast path: already an integer *) 299 + let idx = match index with 300 + | Int i -> Int32.to_int i 301 + | Float f when f >= 0.0 && f < 2147483648.0 && Float.is_integer f -> int_of_float f 302 + | _ -> Int32.to_int (to_int32 index) 303 + in 299 304 if idx < 0 || idx >= length then Undefined 300 305 else 301 306 (* Read element from typed array buffer - handles both ArrayBuffer and SharedArrayBuffer *) ··· 414 419 end; 415 420 value 416 421 | Object ({ data = Data_typed_array { buffer; byte_offset; length }; class_id; _ }) -> 417 - let idx = Int32.to_int (to_int32 index) in 422 + (* Fast path: already an integer *) 423 + let idx = match index with 424 + | Int i -> Int32.to_int i 425 + | Float f when f >= 0.0 && f < 2147483648.0 && Float.is_integer f -> int_of_float f 426 + | _ -> Int32.to_int (to_int32 index) 427 + in 418 428 if idx >= 0 && idx < length then begin 419 429 (* Get buffer bytes - handles both ArrayBuffer and SharedArrayBuffer *) 420 430 let buf = match buffer.data with