-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Performance tweaks #3468
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: v3/master
Are you sure you want to change the base?
Performance tweaks #3468
Changes from 2 commits
907d7f8
12671d1
e9bf9ad
e4f3feb
c7b2fdf
ef42d05
72b46c5
c9f2f35
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -195,7 +195,7 @@ bool RulesExceptions::contains(int a) { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| for (auto z : m_ranges) { | ||||||
| for (auto& z : m_ranges) { | ||||||
|
||||||
| for (auto& z : m_ranges) { | |
| for (const auto& z : m_ranges) { |
Please see cppcheck's warning:
warning: src/rules_exceptions.cc,198,style,constVariableReference,Variable 'z' can be declared as reference to const
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.
Sonarcloud also reports this.
Outdated
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 (auto& b : from->m_ranges) { | |
| for (const auto& b : from->m_ranges) { |
Please see cppcheck's warning:
warning: src/rules_exceptions.cc,215,style,constVariableReference,Variable 'b' can be declared as reference to const
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1700,7 +1700,7 @@ std::string Transaction::toJSON(int parts) { | |||||
| reinterpret_cast<const unsigned char*>("messages"), | ||||||
| strlen("messages")); | ||||||
| yajl_gen_array_open(g); | ||||||
| for (auto a : m_rulesMessages) { | ||||||
| for (auto& a : m_rulesMessages) { | ||||||
|
||||||
| for (auto& a : m_rulesMessages) { | |
| for (const auto& a : m_rulesMessages) { |
Probably here you could use const too.
Outdated
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 (auto& b : a.m_tags) { | |
| for (const auto& b : a.m_tags) { |
Probably here you could use const too.
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.
The original code was written about 8 years ago, the author is no longer involved in development.
If I had to guess why they used value copy mechanism, I would say they wanted to avoid any chance to modify the value on Lua stack (except for intentional change with
setvar()).If we want to keep this restriction, please consider to use
constmodifier here.