Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make String move constructor move instead of copy. #21

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

Merged
aentinger merged 2 commits into arduino:master from leg0:proper_string_move
May 25, 2021

Conversation

Copy link
Contributor

@leg0 leg0 commented Nov 15, 2018

The move constructor String::String(String&&) and String::operator=(String&&)
now perform move instead of copy.

Remove String(StringSumHelper&&) constructor because having it makes no sense:
String(String&&) takes care of it - you can pass either String&& or
StringSumHelper&& to this constructor. StringSumHelper is derived from String
and has no data members other than those inherited from String. Even if it did
have some extra data members, truncation would have to happen during move, and
normally that is something you don't want.

Copy link

CLAassistant commented Apr 9, 2021
edited
Loading

CLA assistant check
All committers have signed the CLA.

@leg0 leg0 force-pushed the proper_string_move branch from 76fa259 to 14e923e Compare April 20, 2021 00:44
Copy link
Contributor Author

leg0 commented Apr 20, 2021
edited
Loading

This fixes #146.
Original PR for reference: arduino/Arduino#6261

Copy link
Collaborator

@matthijskooijman matthijskooijman left a comment

Choose a reason for hiding this comment

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

I had a look at this, the new implementation of the move() method looks good to me, as do the new testcases.

I did leave some comments inline about the other changes you made, please have a look at those.

Copy link

Codecov Report

Merging #21 (e414de7) into master (e2d2f20) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@
## master #21 +/- ##
==========================================
- Coverage 96.04% 96.00% -0.04% 
==========================================
 Files 13 13 
 Lines 835 827 -8 
==========================================
- Hits 802 794 -8 
 Misses 33 33 
Impacted Files Coverage Δ
api/String.h 90.00% <ø> (ø)
api/String.cpp 97.65% <100.00%> (-0.05%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2d2f20...e414de7. Read the comment docs.

leg0 added 2 commits April 22, 2021 12:29
The move constructor String::String(String&&) and String::operator=(String&&)
now perform move instead of copy.
Remove String(StringSumHelper&&) constructor because having it makes no sense:
String(String&&) takes care of it - you can pass either String&& or
StringSumHelper&& to this constructor. StringSumHelper is derived from String
and has no data members other than those inherited from String. Even if it did
have some extra data members, truncation would have to happen during move, and
normally that is something you don't want.
@leg0 leg0 force-pushed the proper_string_move branch from e414de7 to 41599a3 Compare April 22, 2021 09:31
Copy link
Collaborator

@matthijskooijman matthijskooijman left a comment

Choose a reason for hiding this comment

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

Looks good to me now, thanks!

Copy link
Contributor

@aentinger aentinger left a comment

Choose a reason for hiding this comment

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

Good work! Thank you @leg0 and @matthijskooijman 🚀

@aentinger aentinger merged commit 42f8e11 into arduino:master May 25, 2021
@leg0 leg0 deleted the proper_string_move branch May 25, 2021 12:08
mysterywolf pushed a commit to RTduino/RTduino that referenced this pull request Sep 15, 2024
The move constructor String::String(String&&) and String::operator=(String&&)
now perform move instead of copy.
Remove String(StringSumHelper&&) constructor because having it makes no sense:
String(String&&) takes care of it - you can pass either String&& or
StringSumHelper&& to this constructor. StringSumHelper is derived from String
and has no data members other than those inherited from String. Even if it did
have some extra data members, truncation would have to happen during move, and
normally that is something you don't want.
cherry-pick from: arduino/ArduinoCore-API#21 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@matthijskooijman matthijskooijman matthijskooijman approved these changes

+1 more reviewer

@aentinger aentinger aentinger approved these changes

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

String::substring deferences NULL if the returned value is the empty string. This is due to a bug in String::move

AltStyle によって変換されたページ (->オリジナル) /