-
Notifications
You must be signed in to change notification settings - Fork 2
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
alloca() #2
Comments
Sure. Are you aware of any ways to get alloca() working on Rust? |
Not really. Did you read rust-lang/rfcs#618 ? There's a link to an RFC at the bottom: rust-lang/rfcs#1808 |
Thanks! I'll take a look. |
Given that the obstacks implementation already minimizes allocations - particularly if you set an appropriately large initial capacity - I have to wonder how much of a performance benefit this would actually be? I mean, if you have a working alloca(), it might be better to just use it directly. Also, unlike alloca(), an obstack can be passed to child functions that can in turn add things to the stack, and return references to values within it; I don't see how you could preserve that capability. That said, what I could do is make the initial allocation on the stack, then switch to the heap when that allocation runs out. That'd probably give you very similar benefits to alloca() for many usecases while still preserving the ability to pass the stack to child functions. Specifically, I could do this by adding another constructor,
(or via something like ArrayVec to avoid unsafeness) |
Would it be possible to use alloca() when available ? This would make allocations equivalent to just a pointer adjust.
The text was updated successfully, but these errors were encountered: