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:
parent
36e486dbc1
commit
4564fd7472
1 changed files with 2 additions and 2 deletions
|
@ -11,7 +11,7 @@ module AwesomePrint
|
||||||
|
|
||||||
attr_reader :inspector, :options
|
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)
|
def initialize(inspector)
|
||||||
@inspector = inspector
|
@inspector = inspector
|
||||||
|
@ -34,7 +34,7 @@ module AwesomePrint
|
||||||
# directory for custom formatters that ship with awesome_print.
|
# directory for custom formatters that ship with awesome_print.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
def cast(object, type)
|
def cast(object, type)
|
||||||
CORE.grep(type)[0] || :self
|
CORE_FORMATTERS.include?(type) ? type : :self
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in a new issue