grain-lang / grain

The Grain compiler toolchain and CLI. Home of the modern web staple. 🌾
https://grain-lang.org/
GNU Lesser General Public License v3.0
3.28k stars 115 forks source link

feat(runtime): Simplify `copy` and `fill` polyfills in `Memory` module #2148

Closed spotandjake closed 3 months ago

spotandjake commented 3 months ago

This pr simplifies the Memory.copy and Memory.fill polyfills in Memory.gr, I implemented them using a for loop as it means less mutable variables compared to the while loop approach and makes the code a lot easier to follow.

Additionally this removes a few operations per cycle on the functions as we are not modifying as many values every iteration.