Skip to content

Commit

Permalink
fix a caching bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeInnes committed Jun 4, 2017
1 parent ebb5479 commit 2790847
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Lazy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,18 @@ isempty(::LinkedList) = false

# Lazy Lists

function realise(xs::LazyList)
function realise!(xs::LazyList)
xs.realised && return xs.list
xs.realised = true
xs.list = xs.f()
return xs.list
end

function realise(xs::LazyList)
realise!(xs)
# Unroll in a loop to avoid overflow
while isa(xs.list, LazyList)
xs.list = xs.list.f()
xs.list = realise!(xs.list)
end
return xs.list
end
Expand Down

1 comment on commit 2790847

@tkelman
Copy link
Contributor

@tkelman tkelman commented on 2790847 Jun 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should write tests for whatever was broken when you fix bugs

Please sign in to comment.