From 155e9ec81a70cfe0f991c06f69580082de30cfc3 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 14 Oct 2018 19:08:07 -0600 Subject: [PATCH] Store example count instead of recalculating --- src/spectator/example_group.cr | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/spectator/example_group.cr b/src/spectator/example_group.cr index 4277fd6..06a61f9 100644 --- a/src/spectator/example_group.cr +++ b/src/spectator/example_group.cr @@ -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