Skip to content

Commit 403dcb4

Browse files
authored
inline iterate method to avoid allocations (#148)
Use `@inline` on iterate method of Combinations to avoid allocations when creating return tuple
1 parent c663926 commit 403dcb4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/combinations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct Combinations
1010
t::Int
1111
end
1212

13-
function Base.iterate(c::Combinations, s = [min(c.t - 1, i) for i in 1:c.t])
13+
@inline function Base.iterate(c::Combinations, s = [min(c.t - 1, i) for i in 1:c.t])
1414
if c.t == 0 # special case to generate 1 result for t==0
1515
isempty(s) && return (s, [1])
1616
return

0 commit comments

Comments
 (0)