From b478768602ee8d9aa68f62efc63a8e812c401c80 Mon Sep 17 00:00:00 2001 From: Felipe Noronha Date: Sat, 21 Aug 2021 12:45:09 -0300 Subject: [PATCH] avoid vector allocation when PartitionIterator is cut short --- base/iterators.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/iterators.jl b/base/iterators.jl index f9728cbbd0793..c0a68a36d836e 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -1191,11 +1191,11 @@ end struct IterationCutShort; end function iterate(itr::PartitionIterator, state...) - v = Vector{eltype(itr.c)}(undef, itr.n) # This is necessary to remember whether we cut the # last element short. In such cases, we do return that # element, but not the next one state === (IterationCutShort(),) && return nothing + v = Vector{eltype(itr.c)}(undef, itr.n) i = 0 y = iterate(itr.c, state...) while y !== nothing