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

usb/cdc: writing small blocks should not require allocation #991

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smurfix
Copy link
Contributor

@smurfix smurfix commented Mar 26, 2025

Only allocate a memoryview when the (first) write was partial.

Signed-off-by: Matthias Urlichs <matthias@urlichs.de>
start = time.ticks_ms()
mv = memoryview(buf)
# use a memoryview to track partial writes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a neat optimisation, thanks!

But I suggest more detail in this comment, something like "if buf can't be fully written on the first attempt then it will be converted to a memoryview to track partial writes".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will update.

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