[ruby/psych] Avoid calls to require
in hotspots
Followup: https://github.com/ruby/psych/pull/686 This single call shows up as 4% of some controller actions in the lobsters benchmark. Profile: https://share.firefox.dev/3EqKnhS https://github.com/ruby/psych/commit/b77bfee092
This commit is contained in:
parent
599fdb9641
commit
c1f024f99d
@ -55,7 +55,8 @@ module Psych
|
|||||||
#
|
#
|
||||||
# See also Psych::Visitors::Emitter
|
# See also Psych::Visitors::Emitter
|
||||||
def yaml io = nil, options = {}
|
def yaml io = nil, options = {}
|
||||||
require "stringio"
|
require "stringio" unless defined?(StringIO)
|
||||||
|
|
||||||
real_io = io || StringIO.new(''.encode('utf-8'))
|
real_io = io || StringIO.new(''.encode('utf-8'))
|
||||||
|
|
||||||
Visitors::Emitter.new(real_io, options).accept self
|
Visitors::Emitter.new(real_io, options).accept self
|
||||||
|
Loading…
x
Reference in New Issue
Block a user