Skip to content

Commit 5c04045

Browse files
authored
Merge pull request ruby#3495 from ruby/dont-require-set-until-needed
Use Set.new over to_set
2 parents 8b2dd0d + 422d5c4 commit 5c04045

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

lib/prism/translation/parser/lexer.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "set"
43
require "strscan"
54
require_relative "../../polyfill/append_as_bytes"
65

@@ -11,7 +10,7 @@ class Parser
1110
# format for the parser gem.
1211
class Lexer
1312
# These tokens are always skipped
14-
TYPES_ALWAYS_SKIP = %i[IGNORED_NEWLINE __END__ EOF].to_set
13+
TYPES_ALWAYS_SKIP = Set.new(%i[IGNORED_NEWLINE __END__ EOF])
1514
private_constant :TYPES_ALWAYS_SKIP
1615

1716
# The direct translating of types between the two lexers.
@@ -196,18 +195,18 @@ class Lexer
196195
#
197196
# NOTE: In edge cases like `-> (foo = -> (bar) {}) do end`, please note that `kDO` is still returned
198197
# instead of `kDO_LAMBDA`, which is expected: https://github.com/ruby/prism/pull/3046
199-
LAMBDA_TOKEN_TYPES = [:kDO_LAMBDA, :tLAMBDA, :tLAMBEG].to_set
198+
LAMBDA_TOKEN_TYPES = Set.new([:kDO_LAMBDA, :tLAMBDA, :tLAMBEG])
200199

201200
# The `PARENTHESIS_LEFT` token in Prism is classified as either `tLPAREN` or `tLPAREN2` in the Parser gem.
202201
# The following token types are listed as those classified as `tLPAREN`.
203-
LPAREN_CONVERSION_TOKEN_TYPES = [
202+
LPAREN_CONVERSION_TOKEN_TYPES = Set.new([
204203
:kBREAK, :kCASE, :tDIVIDE, :kFOR, :kIF, :kNEXT, :kRETURN, :kUNTIL, :kWHILE, :tAMPER, :tANDOP, :tBANG, :tCOMMA, :tDOT2, :tDOT3,
205204
:tEQL, :tLPAREN, :tLPAREN2, :tLPAREN_ARG, :tLSHFT, :tNL, :tOP_ASGN, :tOROP, :tPIPE, :tSEMI, :tSTRING_DBEG, :tUMINUS, :tUPLUS
206-
].to_set
205+
])
207206

208207
# Types of tokens that are allowed to continue a method call with comments in-between.
209208
# For these, the parser gem doesn't emit a newline token after the last comment.
210-
COMMENT_CONTINUATION_TYPES = [:COMMENT, :AMPERSAND_DOT, :DOT].to_set
209+
COMMENT_CONTINUATION_TYPES = Set.new([:COMMENT, :AMPERSAND_DOT, :DOT])
211210
private_constant :COMMENT_CONTINUATION_TYPES
212211

213212
# Heredocs are complex and require us to keep track of a bit of info to refer to later

0 commit comments

Comments
 (0)