Skip to content

added filter and reduce, optimized forEach / map#2

Open
KevinGin wants to merge 2 commits intogyllstromk:masterfrom
KevinGin:master
Open

added filter and reduce, optimized forEach / map#2
KevinGin wants to merge 2 commits intogyllstromk:masterfrom
KevinGin:master

Conversation

@KevinGin
Copy link
Copy Markdown

Hi,

I added two more iterators -- filter and reduce -- which work as would be expected. I also added tests for each of these new features.

In addition, I optimized the forEach / map methods by specifying the array size up front. (Rather than starting with an empty array and pushing to it, which causes the array to resize under the hood as it grows). I created a Gist to show what I used to compare runtimes. The optimized method seems to be around 4x faster: https://gist.github.com/KevinGin/0bc39e390e2b780122747d1f9a98ed56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant