-
Notifications
You must be signed in to change notification settings - Fork 66
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
fast path for vec_slice(x, <vector of only TRUE>)
?
#1400
Comments
vec_slice(x, TRUE)
?vec_slice(x, <vector of only TRUE>)
?
Your second bullet point is similar to what |
I added an example to the second bullet point. I really meant looping over a list and slicing every element of a list under some (rare) condition. Though, now that I think about it I'm not sure how much more efficient this is as the result is a new list anyway. |
I think this makes sense, and the Given the modularity of the internals, it might be best to implement this via the compact subscripts. The C-level |
Implemented in #1408 but we decided to close. |
I'm not sure how often this is actually relevant in real life but it might be worth to have a "fast path" in
vec_slice()
when thei
is a logical vector where every element isTRUE
.This would avoid copying all of
x
and therefore be much faster and memory friendly. At first it might seem unlikely to have allTRUE
but I can see two likely scenarios:NA
, e.g.vec_slice(out, !vec_equal_na(vals))
,Having a quick look at the source code the check might be relatively cheap to do in
lgl_as_location()
resp. inr_lgl_which()
.The text was updated successfully, but these errors were encountered: