Skip to content

Commit

Permalink
Chore: Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Oscar Spencer <[email protected]>
  • Loading branch information
spotandjake and ospencer authored Feb 16, 2025
1 parent 54c6dd7 commit 3a46de2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions stdlib/array.gr
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ provide let init = (length: Number, fn: Number => a) => {
}

/**
* Creates a new array of the specified length where each element is
* initialized with the result of an initializer function. The initializer
* is called with the index of each array element. If the initializer function
* returns `Err(_)`, the array creation is stopped and the error is returned.
* Creates a new array where each element is initialized with the `Ok`
* value result of an initializer function. The initializer is called with the
* index of each element. Returns the new array if all calls to the
* initializer succeed or the first error otherwise.
*
* @param length: The length of the new array
* @param fn: The initializer function to call with each index, where the value returned will be used to initialize the element
Expand Down Expand Up @@ -169,7 +169,8 @@ provide let tryInit = (length: Number, fn: Number => Result<a, b>) => {
},
Err(e) => {
for (let mut j = 0n; j < i; j += 4n) {
ignore(Memory.decRef(WasmI32.load(array, _ARRAY_START_OFFSET + j)))
Memory.decRef(WasmI32.load(array, _ARRAY_START_OFFSET + j))
Memory.free(array)
}
return Err(e)
},
Expand Down

0 comments on commit 3a46de2

Please sign in to comment.