Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize bsearchIndex method #70

Open
kiellabian opened this issue Feb 18, 2019 · 1 comment
Open

Optimize bsearchIndex method #70

kiellabian opened this issue Feb 18, 2019 · 1 comment

Comments

@kiellabian
Copy link

Currently, the bsearchIndex method is using slice, which creates a partial, shallow copy of the original array into a new array -- meaning it uses extra memory. This extra memory is unnecessary and will scale when handling large arrays. We can avoid this with simple manipulation of the starting and ending indexes ("i" and "j", respectively).

Moreover, instead of using recursion, this can be done with a loop which is actually more efficient.

Lastly, it will be helpful if this phrase is added in the docs:
Use bsearchIndex or bsearch on arrays, assuming it is already sorted.

@arnellebalane
Copy link
Member

arnellebalane commented Feb 19, 2019

@kiellabian Thanks for these suggestions, they all sound great! 🎉

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

No branches or pull requests

2 participants