-
Notifications
You must be signed in to change notification settings - Fork 323
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
Add Vector.take
and Vector.drop
functions
#3629
Conversation
e0685bd
to
f53c9a4
Compare
c37bc3d
to
bf2ca66
Compare
03e8768
to
b46ae97
Compare
bf2ca66
to
8474e25
Compare
8474e25
to
10e1608
Compare
c435c83
to
a496710
Compare
10e1608
to
e7764df
Compare
slice_ranges vector ranges = | ||
if ranges.length == 0 then empty else case ranges.length == 1 of | ||
True -> case ranges.first of | ||
Integer -> Vector (Array.new_1 (vector.unsafe_at ranges.first)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this special case, because it can be triggered relatively often by vec.take (By_Index 123)
. It seemed that creating a slice just to hold a single element will be an overkill - because the cost of allocating the atom representing the slice descriptor should be roughly the same as the cost of allocating a single-element array and the memory footprint of both of these is also comparable, so it seems to me that making a slice for just a single element would be wasteful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do a faster short circuit earlier that if By_Index is an Integer or a single Integer Vector we return just self.at index
and let the self.at do the checking and resolving,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but then again I still need to do the check at slice_ranges
for a single range - so I still need this case-of but now it will be in two places.
c39dc9f
to
b6b17e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to have a think on the normalize_ranges
and invert
but generally looks good.
slice_ranges vector ranges = | ||
if ranges.length == 0 then empty else case ranges.length == 1 of | ||
True -> case ranges.first of | ||
Integer -> Vector (Array.new_1 (vector.unsafe_at ranges.first)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do a faster short circuit earlier that if By_Index is an Integer or a single Integer Vector we return just self.at index
and let the self.at do the checking and resolving,
5513e6b
to
46695cf
Compare
TODO: fix a regression
…be used there once it is implemented
…ilar seeds so lots of samples are needed Also, fixed the offset in should_contain_the_same_elements
46695cf
to
16a458f
Compare
Pull Request Description
Implements https://www.pivotaltracker.com/story/show/182307048
Important Notes
Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide dist
and./run ide watch
.