Skip to content

Commit d426bda

Browse files
authored
Merge pull request #553 from adienes/length_string_trap
simple_hash faster by lifting length(str)
2 parents ef9b8dd + 542dcd7 commit d426bda

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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)