summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2021-01-30 13:41:12 +0100
committerJean Boussier <jean.boussier@gmail.com>2021-01-30 13:41:12 +0100
commit58223f04260681ebf11e8c60b9cf1b744d07a67a (patch)
tree1d3c2c9a01d265cfc5bf5a0d9151bbfd033989c7
parent0abce07b908fa0128223a3e11f2eeb4be0c191d6 (diff)
downloadpsych-58223f04260681ebf11e8c60b9cf1b744d07a67a.zip
Cache access to Psych.load_tags in Visitor::ToRuby
-rw-r--r--lib/psych/visitors/to_ruby.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb
index ec80701..a100188 100644
--- a/lib/psych/visitors/to_ruby.rb
+++ b/lib/psych/visitors/to_ruby.rb
@@ -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