Movatterモバイル変換


[0]ホーム

URL:


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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aentinger merged 2 commits intoarduino:masterfromleg0:proper_string_move
May 25, 2021

Conversation

leg0
Copy link
Contributor

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.

@CLAassistant
Copy link

CLAassistant commentedApr 9, 2021
edited
Loading

CLA assistant check
All committers have signed the CLA.

@leg0
Copy link
ContributorAuthor

leg0 commentedApr 20, 2021
edited
Loading

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

Copy link
Collaborator

@matthijskooijmanmatthijskooijman 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 themove() 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.

@codecov-commenter
Copy link

Codecov Report

Merging#21 (e414de7) intomaster (e2d2f20) willdecrease coverage by0.03%.
The diff coverage is100.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 FilesCoverage Δ
api/String.h90.00% <ø> (ø)
api/String.cpp97.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 byCodecov. Last updatee2d2f20...e414de7. Read thecomment docs.

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&& orStringSumHelper&& to this constructor. StringSumHelper is derived from Stringand has no data members other than those inherited from String. Even if it didhave some extra data members, truncation would have to happen during move, andnormally that is something you don't want.
Copy link
Collaborator

@matthijskooijmanmatthijskooijman 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

@aentingeraentinger 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 🚀

@aentingeraentinger merged commit42f8e11 intoarduino:masterMay 25, 2021
@leg0leg0 deleted the proper_string_move branchMay 25, 2021 12:08
mysterywolf pushed a commit to RTduino/RTduino that referenced this pull requestSep 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&& orStringSumHelper&& to this constructor. StringSumHelper is derived from Stringand has no data members other than those inherited from String. Even if it didhave some extra data members, truncation would have to happen during move, andnormally that is something you don't want.cherry-pick from:arduino/ArduinoCore-API#21
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@matthijskooijmanmatthijskooijmanmatthijskooijman approved these changes

@aentingeraentingeraentinger approved these changes

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
5 participants
@leg0@CLAassistant@codecov-commenter@matthijskooijman@aentinger

[8]ページ先頭

©2009-2025 Movatter.jp