Skip to content

lsm6ds3tr: avoid unnecessary heap allocations (alternative) #769

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

Closed
wants to merge 1 commit into from

Conversation

ysoldak
Copy link
Contributor

@ysoldak ysoldak commented Jun 21, 2025

This is an alternative implementation of #766

The difference is here we store read result into the buffer w/o an offset -> easier to work with. 🤩
Also, this implementation saves one byte, since we don't need one extra in the buffer anymore.

💣 This assumes however that I2C implementation does not clean the destination buffer prior to filling it.

💡 We can still have the read data be stored w/o offset in the buffer, but that requires making the buffer bigger again and then copy(d.buf[0:size), d.buf[1:size+1)) which is probably suboptimal too.

@ysoldak
Copy link
Contributor Author

ysoldak commented Jun 23, 2025

Closing in favor of the original #766 as it now achieved same level of internal api clearness w/o extra assumptions about I2C implementation.

@ysoldak ysoldak closed this Jun 23, 2025
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.

1 participant