-
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 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -195,7 +195,7 @@ bool RulesExceptions::contains(int a) { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| for (auto z : m_ranges) { | ||||||
| for (auto& z : m_ranges) { | ||||||
|
Member
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.
Suggested change
Please see
Member
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. Sonarcloud also reports this. |
||||||
| if (z.first <= a && z.second >= a) { | ||||||
| return true; | ||||||
| } | ||||||
|
|
@@ -212,7 +212,7 @@ bool RulesExceptions::merge(RulesExceptions *from) { | |||||
| return ret; | ||||||
| } | ||||||
| } | ||||||
| for (auto b : from->m_ranges) { | ||||||
| for (auto& b : from->m_ranges) { | ||||||
|
Member
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.
Suggested change
Please see cppcheck's warning: |
||||||
| bool ret = addRange(b.first, b.second); | ||||||
| if (ret == false) { | ||||||
| return ret; | ||||||
|
|
||||||
| 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) { | ||||||
|
Member
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.
Suggested change
Probably here you could use |
||||||
| yajl_gen_map_open(g); | ||||||
| LOGFY_ADD("message", a.m_message); | ||||||
| yajl_gen_string(g, | ||||||
|
|
@@ -1721,7 +1721,7 @@ std::string Transaction::toJSON(int parts) { | |||||
| reinterpret_cast<const unsigned char*>("tags"), | ||||||
| strlen("tags")); | ||||||
| yajl_gen_array_open(g); | ||||||
| for (auto b : a.m_tags) { | ||||||
| for (auto& b : a.m_tags) { | ||||||
|
Member
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.
Suggested change
Probably here you could use |
||||||
| yajl_gen_string(g, | ||||||
| reinterpret_cast<const unsigned char*>(b.data()), | ||||||
| b.length()); | ||||||
|
|
||||||
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.