File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1284,15 +1284,23 @@ function lex_backtick(l::Lexer)
1284
1284
end
1285
1285
1286
1286
const MAX_KW_LENGTH = 10
1287
+ const ascii_is_identifier_char::Vector{Bool} = map(is_identifier_char ∘ Char, 0x00:0x7f)
1287
1288
function lex_identifier(l::Lexer, c)
1288
1289
h = simple_hash(c, UInt64(0))
1289
1290
n = 1
1290
- graphemestate = Ref(zero(Int32))
1291
+ ascii = isascii(c)
1292
+ graphemestate = Ref(Int32(ascii)) # all ASCII id chars are UTF8PROC_BOUNDCLASS_OTHER
1291
1293
graphemestate_peek = Ref(zero(Int32))
1292
1294
while true
1293
1295
pc, ppc = dpeekchar(l)
1294
- if Unicode.isgraphemebreak!(graphemestate, c, pc)
1295
- if (pc == '!' && ppc == '=') || !is_identifier_char(pc)
1296
+ ascii = ascii && isascii(pc)
1297
+ if ascii # fast path
1298
+ pc_byte = pc % UInt8
1299
+ @inbounds if (pc_byte == UInt8('!') && ppc == '=') || !ascii_identifier_chars[pc_byte+1]
1300
+ break
1301
+ end
1302
+ elseif Unicode.isgraphemebreak!(graphemestate, c, pc)
1303
+ if (pc == '!' && ppc == '=') || !ascii_is_identifier_char(pc)
1296
1304
break
1297
1305
end
1298
1306
elseif pc in ('\u200c','\u200d') # ZWNJ/ZWJ control characters
You can’t perform that action at this time.
0 commit comments