-
Notifications
You must be signed in to change notification settings - Fork 48
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
[Long-term] Specialize wrapper functions for 0-sized closures #108
Comments
In order to be a bit more specific, in Rust a closure is composed of two things: a function and an "environment". The environment contains all the local variables that were captured by the closures. For example if you do In order to make this work, hlua asks lua to allocate some memory, copies the environment inside it, pushes the environment as a "hidden parameter" for the C callback, and when the C callback is called the environment is loaded and the closure is recreated. However many closures and all freestanding functions don't have any environment at all. In this situation hlua still asks lua to allocate 0 byte of memory, pushes the hidden parameter, and when the C callback is called it asks lua to load the zero-sized data. This issue is about removing all these useless steps. |
rust-lang/rust#39817 can possibly help here |
Very long term issue. Requires specialization to be stable and a way to specialize for functions and closures that don't borrow any environment.
The text was updated successfully, but these errors were encountered: