Description
Elixir and Erlang/OTP versions
According to git, the affected code has been unchanged in the last 6 years, so many Elixir versions up to and including current main
are affected.
This issue is not related to any particular Erlang version.
Operating system
any
Current behavior
This is the current code of the sdlibString.Chars
implementations. Look especially at the implementations for Atom/List/Integer/Float.
The Atom/List/Integer implementations are currently remote calls to tiny functions in their respective modules (Atom.to_string
, List.to_string
, etc.).
The Float implementation however is inlined. It contains the same body as the body of Float.to_string.
Expected behavior
I'd expect that:
- either all implementation would delegate to their respective modules (if we prefer 'abstraction'),
- or all implementations to be inlined (which might bring a small increase in performance because there is one less remote function call).
I am not sure which of these two virtues is more important.
But it seems to me that it makes sense to pick a single consistent approach for all implementations.
W.r.t. performance: I have not done any benchmarking to compare this code yet. (There is the rough estimate that remote calls are 8% slower according to Table 1.1 in Erlang's efficiency guide). Turning primitive data structures into strings is however something that happens a lot in many Elixir codebases, so it might be worth it.