From 23d14c64693fd9c47d77dfa1ca436ef2eb12ac2b Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Wed, 15 Sep 2021 12:46:28 -0400 Subject: [PATCH] avoid `Any32` type in `filter` for tuples. fixes #42236 (cherry picked from commit 71349b72c9303fb864a349818f8b126c5aec21df) --- base/tuple.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/tuple.jl b/base/tuple.jl index 421ada47c0c36..1abcccef3dab5 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -357,10 +357,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 ##