-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Steal SmallVec from Servo #16522
Comments
@pcwalton you seem to be the primary author of SmallVec. I'm willing to do the bulk of the migration work, but would appreciate any insights you have on the matter. Is there anything you would change about the impl if you could? One thing that comes to mind is that SmallVec would probably be simpler to implement as a tagged union between a Vec and Slice that does Vecish things but can fail (Result-wise) to insert. Might be possible to bring much of Vec's impl under some common interface to reduce duplication? |
Yeah, it would be slightly less efficient as an enum but much easier to understand. Sounds like a good idea to me. Note that you should extensively unit test it; IIRC the current implementation has some major safety bugs (in iteration I believe). |
So I think my basic idea for this is:
Any thoughts? My largest concern is that this might have performance consequences for Vec itself, which is obviously a big deal. |
Might be worth waiting for something like #15748 to make this less hacky. |
I wonder whether it would make sense to start by moving SmallVec into its own crate and working on improvements? Then Servo and others could use this crate, and if we found that it was common enough (and we were happy with the API) we could eventually move to libcollections. That said, the |
Closing as a duplicate of #4991. The Servo implementation has issues like depending on the drop flag and the design isn't necessarily what Rust wants for the standard library. |
SmallVec is a cool collection (family) that attempts to keep some small constant-sized number of elements in-stack before failing over to heap-allocated Slices.
@aturon has indicated interest in including this, in some form, in libcollections.
The text was updated successfully, but these errors were encountered: