JuliaStrings / InlineStrings.jl

Fixed-width string types for Julia

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible bug in `inlinestrings` for length-1 strings

nilshg opened this issue · comments

Reported on Slack:

julia> using InlineStrings

julia> @time inlinestrings(fill("abcde", 1_000_000));
  0.005492 seconds (5 allocations: 15.259 MiB)

julia> @time inlinestrings(fill("ab", 1_000_000));
  0.005419 seconds (5 allocations: 11.444 MiB)

julia> @time inlinestrings(fill("a", 1_000_000));
ERROR: StackOverflowError:

Kristoffer had a look and his take was:

It recurses here

return _inlinestrings(itr, st, new_eT, IS, newres, i + 1)
until the stack runs out.

The reason is this check:

elseif y !== missing && sizeof(y) < sizeof(eT)
sizeof(y) < sizeof(eT) is false when y == "a" and eT == String1