Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ New features:
Bugfixes:

Other improvements:
- Implements `ST.push` via a call to JavaScript's native `push` instead of `pushAll` (#236 by @i-am-the-slime)

## [v7.2.1](https://github.com/purescript/purescript-arrays/releases/tag/v7.2.1) - 2023-06-13

Expand Down
4 changes: 4 additions & 0 deletions src/Data/Array/ST.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,7 @@ export const toAssocArrayImpl = function (xs) {
for (var i = 0; i < n; i++) as[i] = { value: xs[i], index: i };
return as;
};

export const pushImpl = function (a, xs) {
return xs.push(a);
};
6 changes: 4 additions & 2 deletions src/Data/Array/ST.purs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ foreign import popImpl

-- | Append an element to the end of a mutable array. Returns the new length of
-- | the array.
push :: forall h a. a -> STArray h a -> ST h Int
push a = runSTFn2 pushAllImpl [ a ]
push :: forall h a. a -> (STArray h a) -> ST h Int
push = runSTFn2 pushImpl

foreign import pushImpl :: forall h a. STFn2 a (STArray h a) h Int

-- | Append the values in an immutable array to the end of a mutable array.
-- | Returns the new length of the mutable array.
Expand Down