Skip to content

Commit c1f024f

Browse files
byroothsbt
authored andcommitted
[ruby/psych] Avoid calls to require in hotspots
Followup: ruby/psych#686 This single call shows up as 4% of some controller actions in the lobsters benchmark. Profile: https://share.firefox.dev/3EqKnhS ruby/psych@b77bfee092
1 parent 599fdb9 commit c1f024f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/psych/lib/psych/nodes/node.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def to_ruby(symbolize_names: false, freeze: false, strict_integer: false)
5555
#
5656
# See also Psych::Visitors::Emitter
5757
def yaml io = nil, options = {}
58-
require "stringio"
58+
require "stringio" unless defined?(StringIO)
59+
5960
real_io = io || StringIO.new(''.encode('utf-8'))
6061

6162
Visitors::Emitter.new(real_io, options).accept self

0 commit comments

Comments
 (0)