Skip to content

Commit

Permalink
avoid Any32 type in filter for tuples. fixes #42236
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Sep 15, 2021
1 parent f8d3bd2 commit 71349b7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/tuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ end

## filter ##

filter(f, xs::Tuple) = afoldl((ys, x) -> f(x) ? (ys..., x) : ys, (), xs...)
filter_rec(f, xs::Tuple) = afoldl((ys, x) -> f(x) ? (ys..., x) : ys, (), xs...)

# use Array for long tuples
filter(f, t::Any32) = Tuple(filter(f, collect(t)))
filter(f, t::Tuple) = length(t) < 32 ? filter_rec(f, t) : Tuple(filter(f, collect(t)))

## comparison ##

Expand Down

0 comments on commit 71349b7

Please sign in to comment.