-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add function 'find_and_replace' #13
Conversation
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
std::string output = input; | ||
const std::size_t find_len = find.length(); | ||
const std::size_t replace_len = replace.length(); | ||
if (0u == find_len) { |
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.
We can also check if 0u == input.length()
here.
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.
Would this improve anything? We won't enter the while-loop anyways.
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.
Few minor suggestions and nitpicks, looks good otherwise.
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
9fe5c66
to
eb1ec92
Compare
Signed-off-by: William Woodall <william@osrfoundation.org>
FindT && find, | ||
ReplaceT && replace) | ||
{ | ||
auto input_str = detail::normalize_to_basic_string(input); |
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.
There is one limitation here which is that the three argument normalize to the same char typed basic_string
. Which I think is fine.
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.
Yeah, I think that's okay.
* Add function 'find_and_replace' Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Fix spelling Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Add shortcut for find == replace Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Template on std::basic_string Signed-off-by: Jacob Perron <jacob@openrobotics.org> * changed find_and_replace to accept literals using magic 🌈✨ Signed-off-by: William Woodall <william@osrfoundation.org> * Fix lint Signed-off-by: Jacob Perron <jacob@openrobotics.org>
* Add function 'find_and_replace' Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Fix spelling Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Add shortcut for find == replace Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Template on std::basic_string Signed-off-by: Jacob Perron <jacob@openrobotics.org> * changed find_and_replace to accept literals using magic 🌈✨ Signed-off-by: William Woodall <william@osrfoundation.org> * Fix lint Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This will be used for improvements related to ros2/rmw_fastrtps#277.