Skip to content

Commit

Permalink
perf: redundant equality check in a block
Browse files Browse the repository at this point in the history
Signed-off-by: Šimon Lukašík <[email protected]>
  • Loading branch information
isimluk committed Sep 18, 2023
1 parent 1b2ef89 commit 8555bbe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/config/configure_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def parameter_configuration(name, type = nil, **kwargs, &block)
option_value_type!(name, opts, :deprecated, String)
option_value_type!(name, opts, :obsoleted, String)
if type == :enum
if !opts.has_key?(:list) || !opts[:list].is_a?(Array) || opts[:list].empty? || !opts[:list].all?{|v| v.is_a?(Symbol) }
if !opts.has_key?(:list) || !opts[:list].is_a?(Array) || opts[:list].empty? || !opts[:list].all?(Symbol)
raise ArgumentError, "#{name}: enum parameter requires :list of Symbols"
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/config/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def self.enum_value(val, opts = {}, name = nil)

s = val.to_sym
list = opts[:list]
raise "Plugin BUG: config type 'enum' requires :list of symbols" unless list.is_a?(Array) && list.all?{|v| v.is_a? Symbol }
raise "Plugin BUG: config type 'enum' requires :list of symbols" unless list.is_a?(Array) && list.all?(Symbol)
unless list.include?(s)
raise ConfigError, "valid options are #{list.join(',')} but got #{val}"
end
Expand Down

0 comments on commit 8555bbe

Please sign in to comment.