-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Simplified constructors, copy constructors & assignment operators #3248
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
Simplified constructors, copy constructors & assignment operators #3248
Conversation
b95abc9
to
c2a879e
Compare
The tool is reporting duplicate code on changes to data the initialization of data members that were simplified (in The other two files mentioned are This PR is actually about removing code, but Sonarcloud will Sonarcloud...😊 |
I didn't look into updating the PS: I'll take a look at the |
Done PS: Notice that Sonarcloud once again run on stale code after the push, and is still showing the old version of |
55d3483
to
798b4b6
Compare
…ker & Action - Declare other unsupported copy constructor & assignment operators as deleted too (RuleWithActions, RuleUnconditional & RuleScript)
…ues in RuleMessage - Because the lifetime of the RuleMessage instances do not extend beyond the lifetime of the enclosing RuleWithActions & Transaction, RuleMessage can just reference it and simplify its definition. - Additionally, make the references const to show that it doesn't modify it. - Replace RuleMessage copy constructor with default implementations. - Removed unused RuleMessage assignment operator (which cannot be implemented now that it has reference members). - Removed constructor from RuleMessage pointer. - Addressed Sonarcloud suggestions: Do not use the constructor's initializer list for data member "xxx". Use the in-class initializer instead.
798b4b6
to
3358a37
Compare
Edited commits to address the following issues reported by Sonarcloud:
Did not address:
|
- Leverage delegating constructor to avoid code duplication between the two available Transaction constructors. - The constructor without 'id' argument delegates to the one that receives it by providing `nullptr` as a value, which is used to flag that an id needs to be generated. - Simplified constructor by removing member initialization where the default constructor will be invoked.
3358a37
to
6ecfee7
Compare
|
Even though the goal of the PR is to simplify the codebase, commit 2ad87f6 (Reference RuleWithActions & Transaction object instead of copying values in RuleMessage) provides some performance improvements because it removes a number of variables copied from the associated rule & transaction. These results were obtained running the
|
Hi @eduar-hte thanks again for this great PR! Just one reminder to myself:
Seems like the Transaction *modsecTransaction = new Transaction(modsec, rules); or in source documentation, so we need to align them. |
what
Several constructors, copy constructors & assignment operators in the codebase can be simplified or even removed because they're not used.
why
Simplify the codebase making it easier to maintain.
NOTE: In the case of
RuleMessage
, it addresses one of theFIXME
in the codebase, see heremisc
This is part of a series of PRs to improve performance of the library (5/n). Previous: #3231