Skip to content

Commit 09b201c

Browse files
committed
Clean up replace code
1 parent 6ad051e commit 09b201c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/graphql/language/lexer.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,9 @@ module ByteFor
298298
# To avoid allocating more strings, this modifies the string passed into it
299299
def self.replace_escaped_characters_in_place(raw_string)
300300
raw_string.gsub!(ESCAPED) do |matched_str|
301-
if (res = ESCAPES_REPLACE[matched_str])
302-
res
303-
else
304-
codepoint_1 = ($1 || $2).to_i(16)
305-
codepoint_2 = $3
306-
307-
if codepoint_2
301+
if (point_str_1 = $1 || $2)
302+
codepoint_1 = point_str_1.to_i(16)
303+
if (codepoint_2 = $3)
308304
codepoint_2 = codepoint_2.to_i(16)
309305
if (codepoint_1 >= 0xD800 && codepoint_1 <= 0xDBFF) && # leading surrogate
310306
(codepoint_2 >= 0xDC00 && codepoint_2 <= 0xDFFF) # trailing surrogate
@@ -318,6 +314,8 @@ def self.replace_escaped_characters_in_place(raw_string)
318314
else
319315
[codepoint_1].pack('U'.freeze)
320316
end
317+
else
318+
ESCAPES_REPLACE[matched_str]
321319
end
322320
end
323321
nil

0 commit comments

Comments
 (0)