-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
optimize Symbol
with constant string argument
#32437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ncodeunits(s::String) = Core.sizeof(s) | ||
sizeof(s::String) = Core.sizeof(s) | ||
@pure ncodeunits(s::String) = Core.sizeof(s) | ||
@pure sizeof(s::String) = Core.sizeof(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think inference is supposed to know this one already, and might just need a minor fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually a while ago I specifically told the compiler not to constant prop Strings since it led to extremely long compile times for some packages (if I recall, DiffEq parsing many string literals to input numeric constants).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
purity detection should be able to infer this independently of constant prop though and mark it as pure
Conflicts with the premise of #32368, but otherwise this does seem desirable. |
64f46b8
to
3788389
Compare
Bump. |
Re-bump. |
Re-re-bump. |
3788389
to
9ad8bc8
Compare
Currently code with
Symbol("x")
instead of:x
does not get optimized at all, which could be a gotcha. Allow constant inferring symbol<->string conversions, and allow Symbol as an inlined constant.