summaryrefslogtreecommitdiff
path: root/lib/prism/translation/parser
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-02-15 13:41:40 -0500
committergit <svn-admin@ruby-lang.org>2024-02-15 20:39:50 +0000
commit14a7277da13f4c082850cb30c36f4458b6fd35d1 (patch)
tree1cf18bcdc5748efafaf042b046fbb0f349d669eb /lib/prism/translation/parser
parent87cc2fd015fa7f840ae53bb58472354da754b44d (diff)
[ruby/prism] Speed up creating Ruby AST
When creating the Ruby AST, we were previously allocating Location objects for every node and every inner location. Instead, this commit changes it to pack both the start offset and length into a single u64 and pass that into the nodes. Then, when the locations are requested via a reader method, we lazily allocate the Location objects. https://github.com/ruby/prism/commit/de203dca83 Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Diffstat (limited to 'lib/prism/translation/parser')
-rw-r--r--lib/prism/translation/parser/compiler.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb
index 264d85c261..81156a64c7 100644
--- a/lib/prism/translation/parser/compiler.rb
+++ b/lib/prism/translation/parser/compiler.rb
@@ -1477,7 +1477,7 @@ module Prism
# ^^^^^
def visit_string_node(node)
if node.opening&.start_with?("<<")
- children, closing = visit_heredoc(InterpolatedStringNode.new(node.opening_loc, [node.copy(opening_loc: nil, closing_loc: nil, location: node.content_loc)], node.closing_loc, node.location))
+ children, closing = visit_heredoc(InterpolatedStringNode.new(node.send(:source), node.opening_loc, [node.copy(opening_loc: nil, closing_loc: nil, location: node.content_loc)], node.closing_loc, node.location))
builder.string_compose(token(node.opening_loc), children, closing)
elsif node.opening == "?"
builder.character([node.unescaped, srange(node.location)])