Skip to content

Commit

Permalink
Make filter(f, itr::Skip) return a vector
Browse files Browse the repository at this point in the history
  • Loading branch information
galenlynch committed Mar 30, 2019
1 parent 68fa222 commit 6cec3ac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/skip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ julia> filter(isodd, skip(missing, x))
```
"""
function filter(f, itr::Skip{T, <:AbstractArray}) where T
y = similar(itr.x, eltype(itr))
y = similar(itr.x, eltype(itr), length(itr.x))
out_len = 0
for xi in itr.x
if !isa(xi, T) && f(xi)
Expand Down

1 comment on commit 6cec3ac

@nalimilan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes the number of missing values is very low, or the over-allocation will be significant: AFAIK resize! won't really free space. Anyway, better move this change out of this PR: it's much better if we know that the PR only copies existing code for skipmissing, making it more general. Otherwise it's almost impossible to identify what changed in the middle of code moves.

Please sign in to comment.