ruby/ext/psych
Jean Boussier 30f2d69825 Don't call `Kernel#require` in hot loop
Ref: https://bugs.ruby-lang.org/issues/20641

Even without the reference bug, `require 'date'` isn't cheap.

```ruby

require "benchmark/ips"
require "yaml"
require "date"

100.times do |i|
  $LOAD_PATH.unshift("/tmp/does/not/exist/#{i}")
end
payload = 100.times.map { Date.today }.to_yaml

Benchmark.ips do |x|
  x.report("100 dates") { YAML.unsafe_load(payload) }
end
```

Before:
```
$ ruby /tmp/bench-yaml.rb
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
Warming up --------------------------------------
           100 dates   416.000 i/100ms
Calculating -------------------------------------
           100 dates      4.309k (± 1.2%) i/s -     21.632k in   5.021003s
```

After:
```
$ ruby -Ilib /tmp/bench-yaml.rb
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
Warming up --------------------------------------
           100 dates   601.000 i/100ms
Calculating -------------------------------------
           100 dates      5.993k (± 1.8%) i/s -     30.050k in   5.016079s
```
2024-07-19 20:37:20 +00:00
..
lib Don't call `Kernel#require` in hot loop 2024-07-19 20:37:20 +00:00
.gitignore Ignore yaml source 2022-04-05 14:31:54 +09:00
depend ruby tool/update-deps --fix 2024-04-27 21:55:28 +09:00
extconf.rb [ruby/psych] configure of libyaml couldn't detect "arm64-apple-darwin22" for build host. 2023-01-17 08:26:22 +00:00
psych.c
psych.gemspec [ruby/psych] Provide a 'Changelog' link on rubygems.org/gems/psych 2024-01-17 00:48:52 +00:00
psych.h
psych_emitter.c
psych_emitter.h
psych_parser.c [ruby/psych] Convert some of Parser#parse to Ruby 2022-09-20 00:44:30 +09:00
psych_parser.h
psych_to_ruby.c
psych_to_ruby.h
psych_yaml_tree.c
psych_yaml_tree.h