-
Notifications
You must be signed in to change notification settings - Fork 692
Removed excessive use of std::endl from examples. #1773
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
base: dev
Are you sure you want to change the base?
Removed excessive use of std::endl from examples. #1773
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1773 +/- ##
==========================================
+ Coverage 83.10% 83.23% +0.12%
==========================================
Files 283 283
Lines 48929 48777 -152
Branches 10294 10518 +224
==========================================
- Hits 40664 40598 -66
+ Misses 7126 7040 -86
Partials 1139 1139
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…move-excessive-endl-usage
<< " -g gateway_ip : The IPv4 address of the gateway" << std::endl | ||
<< " -h : Displays this help message and exits" << std::endl | ||
<< " -v : Displays the current version and exists" << std::endl | ||
std::cout << "\nUsage:" |
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.
For the strings like here, the performace doesn't matter actually. Personally, I prefer the original std::endl
which looks clearer.
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 find the '\n' version significantly cleaner to read and visualize how the string will be formatted on the console. Especially for places where clang-format places the << std::endl
on the next line.
I looked over the PR. It seems that there is no permance intensive code that |
Removed excessive use of
std::endl
in examples.Each
std::endl
call flushes the stream in addition to appending a new line ('\n') character if the stream is buffered (std::cout
). Usages of it in the middle of a long string block can cause performance overhead where the stream is repeatedly flushed without a need for it.This PR addresses this issue by replacing calls to
std::endl
in the middle of string blocks with '\n'. In addition the PR groups adjacent C-string literals, by removing the<<
operators between them. Under the C++ standard, adjacently declared C-string literals are packed into a single C-string during compilation.