Store example count instead of recalculating

This commit is contained in:
Michael Miller 2018-10-14 19:08:07 -06:00
parent bcb68a5856
commit 155e9ec81a
1 changed files with 2 additions and 3 deletions

View File

@ -15,6 +15,7 @@ module Spectator
def children=(children : Array(ExampleComponent))
raise "Attempted to reset example group children" if @children
@children = children
@example_count = children.sum(&.example_count)
end
def each
@ -27,9 +28,7 @@ module Spectator
children.each
end
def example_count : Int
children.sum(&.example_count)
end
getter example_count = 0
def [](index : Int) : Example
raise IndexError.new if index < 0