File tree Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ AllCops:
1313Layout/LineLength :
1414 Max : 80
1515
16+ Lint/AmbiguousBlockAssociation :
17+ Enabled : false
18+
1619Lint/DuplicateBranch :
1720 Enabled : false
1821
Original file line number Diff line number Diff line change 2222
2323require_relative "syntax_tree/parser"
2424
25- # We rely on Symbol#name being available, which is only available in Ruby 3.0+.
26- # In case we're running on an older Ruby version, we polyfill it here.
27- unless :+ . respond_to? ( :name )
28- class Symbol # rubocop:disable Style/Documentation
29- def name
30- to_s . freeze
31- end
32- end
33- end
34-
3525# Syntax Tree is a suite of tools built on top of the internal CRuby parser. It
3626# provides the ability to generate a syntax tree from source, as well as the
3727# tools necessary to inspect and manipulate that syntax tree. It can be used to
Original file line number Diff line number Diff line change @@ -1651,6 +1651,20 @@ def format(q)
16511651 # array << value
16521652 #
16531653 class Binary < Node
1654+ # Since Binary's operator is a symbol, it's better to use the `name` method
1655+ # than to allocate a new string every time. This is a tiny performance
1656+ # optimization, but enough that it shows up in the profiler. Adding this in
1657+ # for older Ruby versions.
1658+ unless :+ . respond_to? ( :name )
1659+ using Module . new {
1660+ refine Symbol do
1661+ def name
1662+ to_s . freeze
1663+ end
1664+ end
1665+ }
1666+ end
1667+
16541668 # [untyped] the left-hand side of the expression
16551669 attr_reader :left
16561670
You can’t perform that action at this time.
0 commit comments