Skip to content

Commit 3d62893

Browse files
authored
unify prod(::Tuple{Vararg{Int}}) with a single method (#57628)
One less method.
1 parent 5d6d757 commit 3d62893

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

base/tuple.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,12 +649,15 @@ reverse(t::Tuple) = revargs(t...)
649649

650650
## specialized reduction ##
651651

652-
prod(x::Tuple{}) = 1
653-
# This is consistent with the regular prod because there is no need for size promotion
654-
# if all elements in the tuple are of system size.
655-
# It is defined here separately in order to support bootstrap, because it's needed earlier
656-
# than the general prod definition is available.
657-
prod(x::Tuple{Int, Vararg{Int}}) = *(x...)
652+
# used in bootstrapping
653+
function prod(x::Tuple{Vararg{Int}})
654+
@_terminates_locally_meta
655+
r = 1
656+
for y in x
657+
r *= y
658+
end
659+
r
660+
end
658661

659662
# a version of `in` esp. for NamedTuple, to make it pure, and not compiled for each tuple length
660663
function sym_in(x::Symbol, itr::Tuple{Vararg{Symbol}})

0 commit comments

Comments
 (0)