1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

include? is faster than grep - obv. perf bump

This commit is contained in:
James Cox 2019-01-09 11:52:05 -05:00
parent 36e486dbc1
commit 4564fd7472

View file

@ -11,7 +11,7 @@ module AwesomePrint
attr_reader :inspector, :options
CORE = [:array, :bigdecimal, :class, :dir, :file, :hash, :method, :rational, :set, :struct, :unboundmethod]
CORE_FORMATTERS = [:array, :bigdecimal, :class, :dir, :file, :hash, :method, :rational, :set, :struct, :unboundmethod]
def initialize(inspector)
@inspector = inspector
@ -34,7 +34,7 @@ module AwesomePrint
# directory for custom formatters that ship with awesome_print.
#------------------------------------------------------------------------------
def cast(object, type)
CORE.grep(type)[0] || :self
CORE_FORMATTERS.include?(type) ? type : :self
end
private