Skip to content
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

Use ArrayVec rather than Vec for Device ports() #85

Open
raphaelcohn opened this issue Jul 26, 2021 · 2 comments
Open

Use ArrayVec rather than Vec for Device ports() #85

raphaelcohn opened this issue Jul 26, 2021 · 2 comments

Comments

@raphaelcohn
Copy link

The current code allocates from the heap after already allocating from the stack a suitably sized array. This is inefficient but also unnecessary. Allocating Vecs in library code, as a general principal, should be avoided if at all possible, and, if absolutely necessary, it would be nice to be able to capture failed allocation. It's a long standing source of problems in long-running processes.

@a1ien
Copy link
Owner

a1ien commented Jul 26, 2021

I thinking about this when merge ports method. But as said I want keep dependence small as possible. Use crate for only single function it's too expensive

@raphaelcohn
Copy link
Author

Expensive? I don't think you mean that. Admittedly, ArrayVec doesn't yet have a 1.0 release. If you're reluctant to add this, then could you let me pass in a [MaybeUninit; 7] then and pass back the used length?

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

No branches or pull requests

2 participants