Skip to content

Commit 1142fd4

Browse files
authored
Merge pull request rails#54516 from byroot/opt-gtg-cache
Cache Journey Node#to_s
2 parents f010edc + 0588a46 commit 1142fd4

File tree

1 file changed

+2
-1
lines changed
  • actionpack/lib/action_dispatch/journey/nodes

1 file changed

+2
-1
lines changed

actionpack/lib/action_dispatch/journey/nodes/node.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ class Node # :nodoc:
7474
def initialize(left)
7575
@left = left
7676
@memo = nil
77+
@to_s = nil
7778
end
7879

7980
def each(&block)
8081
Visitors::Each::INSTANCE.accept(self, block)
8182
end
8283

8384
def to_s
84-
Visitors::String::INSTANCE.accept(self, "".dup)
85+
@to_s ||= Visitors::String::INSTANCE.accept(self, "".dup).freeze
8586
end
8687

8788
def to_dot

0 commit comments

Comments
 (0)