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

Stop copying read values in characteristic #26

Closed
wants to merge 1 commit into from

Conversation

Jeroen88
Copy link

@Jeroen88 Jeroen88 commented Apr 30, 2020

readRawData() returns a pointer to m_value now, instead of keeping a second copy of the same data. Small API change, if no data is available, an empty string is returned instead of a NULL. Also readValue() returns a reference to m_value now, thus saving a copy constructor and a second copy of the same string in the sketch.

I am curious what you think of this improvement. There might be more locations in the library to do similar things.

In general though, I believe it is a bad habit to store temporary (read) values in the class instance. This PR is not ideal in that sense (because of original design) but an improvement of the current implementation without any mayor impact.

…second copy of the same data. Small API change, if no data is available, an empty string is returned instead of a NULL. Also readValue() returns a reference to m_value now, thus saving a copy constructor and a second copy of the same string in the sketch
@h2zero
Copy link
Owner

h2zero commented Apr 30, 2020

I like these changes, but I think they would be better applied to the client-long-read-write branch as I am working on changes to the implementation of this code there, and a few of these have already been done there as well.

@Jeroen88
Copy link
Author

Jeroen88 commented Apr 30, 2020

Okay,closing for now. I am looking forward to the new release :)

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.

None yet

2 participants