Skip to content

Commit 8e7a88b

Browse files
author
Robert Mosolgo
authored
Merge pull request #3134 from nvh0412/chore/using-pack-directive-constant-instead-of-string-value
Improve Lexer
2 parents 6ab2ed6 + cae7444 commit 8e7a88b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/graphql/language/lexer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class << self
163163
self.graphql_lexer_en_main = 23;
164164

165165
def self.run_lexer(query_string)
166-
data = query_string.unpack("c*")
166+
data = query_string.unpack(PACK_DIRECTIVE)
167167
eof = data.length
168168

169169
# Since `Lexer` is a module, store all lexer state
@@ -1421,7 +1421,7 @@ def self.emit_string(ts, te, meta, block:)
14211421
quotes_length = block ? 3 : 1
14221422
value = meta[:data][ts + quotes_length, te - ts - 2 * quotes_length].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING) || ''
14231423
line_incr = 0
1424-
if block && !value.length.zero?
1424+
if block && !value.empty?
14251425
line_incr = value.count("\n")
14261426
value = GraphQL::Language::BlockString.trim_whitespace(value)
14271427
end

lib/graphql/language/lexer.rl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ module GraphQL
138138
%% write data;
139139

140140
def self.run_lexer(query_string)
141-
data = query_string.unpack("c*")
141+
data = query_string.unpack(PACK_DIRECTIVE)
142142
eof = data.length
143143

144144
# Since `Lexer` is a module, store all lexer state
@@ -213,7 +213,7 @@ module GraphQL
213213
quotes_length = block ? 3 : 1
214214
value = meta[:data][ts + quotes_length, te - ts - 2 * quotes_length].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING) || ''
215215
line_incr = 0
216-
if block && !value.length.zero?
216+
if block && !value.empty?
217217
line_incr = value.count("\n")
218218
value = GraphQL::Language::BlockString.trim_whitespace(value)
219219
end

0 commit comments

Comments
 (0)