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`, # If no filters were added with `#add_example_filter`,
# then the returned filter will allow all examples to be run. # then the returned filter will allow all examples to be run.
protected def example_filter protected def example_filter
if @filters.empty? case (filters = @filters)
NullExampleFilter.new when .empty? then NullExampleFilter.new
else when .one? then filters.first
CompositeExampleFilter.new(@filters) else CompositeExampleFilter.new(filters)
end end
end end
end end