Skip to content

Commit b9276f6

Browse files
authored
Merge pull request JuliaLang/JuliaSyntax.jl#553 from adienes/length_string_trap
simple_hash faster by lifting length(str)
2 parents c31aa64 + 412c2b6 commit b9276f6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

JuliaSyntax/src/tokenize.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,8 @@ end
13391339
function simple_hash(str)
13401340
ind = 1
13411341
h = UInt64(0)
1342-
while ind <= length(str)
1342+
L = min(lastindex(str), MAX_KW_LENGTH)
1343+
while ind <= L
13431344
h = simple_hash(str[ind], h)
13441345
ind = nextind(str, ind)
13451346
end

0 commit comments

Comments
 (0)