dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
82 stars 27 forks source link

Improve performance of `JArray`'s `operator []=` #1097

Closed HosseinYousefi closed 3 weeks ago

HosseinYousefi commented 3 weeks ago

Unrelated to this PR

AI for me: benchmark if allocating on heap every time just to do []= is more expensive than creating an accessor function that uses the pointer to a variable on the stack to set the array region.

_Originally posted by @HosseinYousefi in https://github.com/dart-lang/native/pull/1095#discussion_r1576413351_

HosseinYousefi commented 3 weeks ago

Benchmark here: https://github.com/HosseinYousefi/jnigen_benchmark/tree/array

So it makes sense to do this.