[ruby/psych] Cache access to Psych.load_tags in Visitor::ToRuby

https://github.com/ruby/psych/commit/58223f0426
This commit is contained in:
Jean Boussier 2021-01-30 13:41:12 +01:00 committed by Hiroshi SHIBATA
parent ab785b28e2
commit 3ab41acd36
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -24,6 +24,7 @@ module Psych
super()
@st = {}
@ss = ss
@load_tags = Psych.load_tags
@domain_types = Psych.domain_types
@class_loader = class_loader
@symbolize_names = symbolize_names
@ -48,7 +49,7 @@ module Psych
end
def deserialize o
if klass = resolve_class(Psych.load_tags[o.tag])
if klass = resolve_class(@load_tags[o.tag])
instance = klass.allocate
if instance.respond_to?(:init_with)
@ -128,7 +129,7 @@ module Psych
end
def visit_Psych_Nodes_Sequence o
if klass = resolve_class(Psych.load_tags[o.tag])
if klass = resolve_class(@load_tags[o.tag])
instance = klass.allocate
if instance.respond_to?(:init_with)
@ -160,8 +161,8 @@ module Psych
end
def visit_Psych_Nodes_Mapping o
if Psych.load_tags[o.tag]
return revive(resolve_class(Psych.load_tags[o.tag]), o)
if @load_tags[o.tag]
return revive(resolve_class(@load_tags[o.tag]), o)
end
return revive_hash(register(o, {}), o) unless o.tag
@ -326,6 +327,7 @@ module Psych
end
private
def register node, object
@st[node.anchor] = object if node.anchor
object