Skip to content

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

Merged
merged 1 commit into from
Dec 20, 2018
Merged

Conversation

tautschnig
Copy link
Collaborator

This enables RAII and a more concise notation.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@@ -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)),
Copy link
Member

Choose a reason for hiding this comment

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

Should _name get a &&?

Copy link
Collaborator Author

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?

Copy link
Member

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.

Copy link
Collaborator Author

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 &&.

@tautschnig tautschnig force-pushed the xml-raii branch 2 times, most recently from 0cd7c02 to 9f96fc4 Compare December 19, 2018 15:24
@tautschnig tautschnig self-assigned this Dec 19, 2018
This enables RAII and a more concise notation.
Copy link
Contributor

@allredj allredj left a 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", {
Copy link
Contributor

Choose a reason for hiding this comment

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

Style

@kroening kroening merged commit 9133f75 into diffblue:develop Dec 20, 2018
@tautschnig tautschnig deleted the xml-raii branch December 20, 2018 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants