Use filter if only one is provided

This is less overhead than creating a composite filter for one child 
filter.
This commit is contained in:
Michael Miller 2021-05-08 22:53:39 -06:00
parent 83d7657b18
commit e7c3d8f060
No known key found for this signature in database
GPG key ID: F9A0C5C65B162436

View file

@ -156,10 +156,10 @@ module Spectator
# If no filters were added with `#add_example_filter`,
# then the returned filter will allow all examples to be run.
protected def example_filter
if @filters.empty?
NullExampleFilter.new
else
CompositeExampleFilter.new(@filters)
case (filters = @filters)
when .empty? then NullExampleFilter.new
when .one? then filters.first
else CompositeExampleFilter.new(filters)
end
end
end