From 4564fd74721562cbef2443f7d97109bf9192343d Mon Sep 17 00:00:00 2001 From: James Cox Date: Wed, 9 Jan 2019 11:52:05 -0500 Subject: [PATCH] include? is faster than grep - obv. perf bump --- lib/awesome_print/formatter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/awesome_print/formatter.rb b/lib/awesome_print/formatter.rb index 98dace1..5090138 100644 --- a/lib/awesome_print/formatter.rb +++ b/lib/awesome_print/formatter.rb @@ -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