Skip to content

Conversation

james7132
Copy link

smallvec seems to be in much higher use than tinyvec, so adding tinyvec tends to increase the amount of work while using lewton as a dependency in a typical build. This PR replaces tinyvec with smallvec as a drop-in replacement.

@est31
Copy link
Member

est31 commented Jun 4, 2022

See the reasons why tinyvec was adopted: #75 . It's 100% safe. But yeah 52 dependents vs 759 dependents...

@james7132
Copy link
Author

I'm not too familiar with the operations being done with the type, but it does seem like it's collecting some kind of stream of bools into a temporary buffer of some kind.

Is the number of elements here bounded? If so, I could switch this to use a on-stack bitset instead, eliminating the dependency entirely.

Otherwise, I'm still going to insist on using smallvec here. I'm trying to minimize the dependency tree of Bevy, which depends transitively on this crate through rodio. This is the only instance of tinyvec in the entire dependency tree, while there are at least 6 uses of smallvec elsewhere.

@james7132
Copy link
Author

Looking again at this, the size of these TinyVecs scale with the number of channels being decoded, which can only go up to 255 due to the limits on u8, and since it's storing bools, using on-stack bitset would only be 32 bytes to cover that entire range. We could skip the branches and the allocations without any unsafe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants