-
Notifications
You must be signed in to change notification settings - Fork 273
Cleanup use of empty strings #4041
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
c851c47
to
8add28f
Compare
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: 8add28f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99533608
8add28f
to
83324e4
Compare
83324e4
to
465e0cc
Compare
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: 465e0cc).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99770135
465e0cc
to
a7364e4
Compare
The test failure appears to be clang-format complaining about one line |
a7364e4
to
68f3400
Compare
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.
This PR failed Diffblue compatibility checks (cbmc commit: 385b7f8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/105262938
Status will be re-evaluated on next push.
Common spurious failures:
-
the cbmc commit has disappeared in the mean time (e.g. in a force-push)
-
the author is not in the list of contributors (e.g. first-time contributors).
-
the compatibility was already broken by an earlier merge.
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 believe this patch does what it claims to. I think it may even improve performance very slightly but I have to know -- why did you decide to do this?
In some prior PR I had something like |
@@ -22,6 +22,6 @@ bool taint_analysis( | |||
const std::string &taint_file_name, | |||
message_handlert &, | |||
bool show_full, | |||
const std::string &json_file_name); | |||
const std::string &json_output_file_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.
How about actually using optionalt
?
On Use s.empty() instead of s == "":
_Traits::length("") will be a compile-time zero; so there is likely no performance benefit. We would need to be convinced that |
There are a couple of cases where one might obtain better clarity by using |
config.main is now optionalt<string> [blocks: #4041]
We previously passed in empty strings. Make explicit that the argument is not required.
The use of "" requires constructing a std::string or dstringt, and then a string comparison. empty() is just an integer comparison (both for std::string an dstringt).
Both std::string and dstringt are default-initialised to an empty string.
The use of "" requires constructing a std::string or dstringt, and then a string comparison. empty() is just an integer comparison (both for std::string an dstringt).
Constructing a dstringt from a C string requires a string table lookup, while the default constructor for a dstringt just zero-initialises an unsigned.
This avoids string table lookups.
Appending "" to a string has no effect.
This avoids constructing an object when we can just use an integer comparison.
385b7f8
to
13b3e4f
Compare
This is follow-up of #4041. It avoids the use of an empty string as indicator of 'no value'.
This is follow-up of #4041. It avoids the use of an empty string as indicator of 'no value'.
Please review commit-by-commit. The common theme to this PR is a review of all uses of
""
.