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
common/options: pass by reference and use user-literals for size #18034
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,7 @@ struct Option { | |
std::vector<const char*> see_also; | ||
|
||
value_t min, max; | ||
std::vector<std::string> enum_allowed; | ||
std::vector<const char*> enum_allowed; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure we want char* rather than std::string here? Not that I'm DEAD SET AGAINST IT, but if we're doing std::string operations with them elsewhere this might be a false economy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i am sure, for smaller memory foot print. a temporary |
||
|
||
bool safe; | ||
|
||
|
@@ -191,23 +191,23 @@ struct Option { | |
tags.push_back(tag); | ||
return *this; | ||
} | ||
Option& add_tag(std::initializer_list<const char*> ts) { | ||
Option& add_tag(const std::initializer_list<const char*>& ts) { | ||
tags.insert(tags.end(), ts); | ||
return *this; | ||
} | ||
Option& add_service(const char* service) { | ||
services.push_back(service); | ||
return *this; | ||
} | ||
Option& add_service(std::initializer_list<const char*> ss) { | ||
Option& add_service(const std::initializer_list<const char*>& ss) { | ||
services.insert(services.end(), ss); | ||
return *this; | ||
} | ||
Option& add_see_also(const char* t) { | ||
see_also.push_back(t); | ||
return *this; | ||
} | ||
Option& add_see_also(std::initializer_list<const char*> ts) { | ||
Option& add_see_also(const std::initializer_list<const char*>& ts) { | ||
see_also.insert(see_also.end(), ts); | ||
return *this; | ||
} | ||
|
@@ -233,9 +233,9 @@ struct Option { | |
return *this; | ||
} | ||
|
||
Option& set_enum_allowed(const std::vector<std::string> allowed) | ||
Option& set_enum_allowed(const std::initializer_list<const char*>& allowed) | ||
{ | ||
enum_allowed = allowed; | ||
enum_allowed.insert(enum_allowed.end(), allowed); | ||
return *this; | ||
} | ||
|
||
|
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 is excellent. Where are these literals defined?
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.
right in this file. line:144.