Skip to content

Commit

Permalink
Avoid calls to require in hotspots
Browse files Browse the repository at this point in the history
Followup: ruby#686

This single call shows up as 4% of some controller actions
in the lobsters benchmark.

Profile: https://share.firefox.dev/3EqKnhS
  • Loading branch information
byroot committed Jan 30, 2025
1 parent 5605134 commit b77bfee
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/psych/nodes/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def to_ruby(symbolize_names: false, freeze: false, strict_integer: false)
#
# See also Psych::Visitors::Emitter
def yaml io = nil, options = {}
require "stringio"
require "stringio" unless defined?(StringIO)

real_io = io || StringIO.new(''.encode('utf-8'))

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

0 comments on commit b77bfee

Please sign in to comment.