mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Store example count instead of recalculating
This commit is contained in:
parent
bcb68a5856
commit
155e9ec81a
1 changed files with 2 additions and 3 deletions
|
@ -15,6 +15,7 @@ module Spectator
|
||||||
def children=(children : Array(ExampleComponent))
|
def children=(children : Array(ExampleComponent))
|
||||||
raise "Attempted to reset example group children" if @children
|
raise "Attempted to reset example group children" if @children
|
||||||
@children = children
|
@children = children
|
||||||
|
@example_count = children.sum(&.example_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
def each
|
def each
|
||||||
|
@ -27,9 +28,7 @@ module Spectator
|
||||||
children.each
|
children.each
|
||||||
end
|
end
|
||||||
|
|
||||||
def example_count : Int
|
getter example_count = 0
|
||||||
children.sum(&.example_count)
|
|
||||||
end
|
|
||||||
|
|
||||||
def [](index : Int) : Example
|
def [](index : Int) : Example
|
||||||
raise IndexError.new if index < 0
|
raise IndexError.new if index < 0
|
||||||
|
|
Loading…
Reference in a new issue