-
Notifications
You must be signed in to change notification settings - Fork 274
Add rvalue constructor to xmlt #3600
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
Conversation
@@ -27,6 +27,13 @@ class xmlt | |||
typedef std::list<xmlt> elementst; | |||
typedef std::map<std::string, std::string> attributest; | |||
|
|||
xmlt(std::string _name, attributest &&_attributes, elementst &&_elements) | |||
: name(std::move(_name)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should _name get a &&
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering how well that would work given the common case is a C string at that point. Or maybe it actually makes no difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::string has a lot of optimisation behind it (I've seen instances with copy-on-write, short-string stored in the class itself, etc.); however, disregarding this, yes, it should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've now added the &&
.
0cd7c02
to
9f96fc4
Compare
This enables RAII and a more concise notation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 61f23cc).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95336005
xmlt edge2("edge"); | ||
edge2.set_attribute("source", graphml[from].node_name); | ||
edge2.set_attribute("target", graphml[sink].node_name); | ||
xmlt edge2("edge", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style
This enables RAII and a more concise notation.