Skip to content

Commit 23d14c6

Browse files
JeffBezansonKristofferC
authored andcommitted
avoid Any32 type in filter for tuples. fixes #42236
(cherry picked from commit 71349b7)
1 parent 9741f5c commit 23d14c6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

base/tuple.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,10 @@ end
357357

358358
## filter ##
359359

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

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

365365
## comparison ##
366366

0 commit comments

Comments
 (0)