php_amule_lib/php_syntree: use some const arguments - #190
Conversation
|
It's okay, but if you started it already, then why didn't you take it all way long? I mean you could also check whether the If the mere reason of existence for a commit is to silence a cppcheck warning, it's likely to be rejected. Also I'd appreciate if you could provide a bit more detailed commit messages. |
|
you are wrong, it can't be done the same with |
How did it fail for you? For me this works. |
777cae7 to
873d5cd
Compare
|
Sorry, you are right, thanks for testing, I forgot to change .h file I updated the PR, please review again |
873d5cd to
ce08f1c
Compare
|
May I give you a task? Array keys are immutable, thus I think all function parameters that are array keys could be changed to a const reference. That would mostly affect php_syntree or maybe php_core_lib. Are you up to the challenge? (And please provide some descriptive commit message, that also tells us why it's better to use a const reference instead of passing an object by value.) |
ce08f1c to
31757ff
Compare
A const reference is a reference that does not allow the variable being referenced to be changed through the reference. Consequently, if we use a const reference as a parameter, we guarantee to the caller that the function will not change the argument.
31757ff to
a5d9609
Compare
|
@gonosztopi please review again |
gonosztopi
left a comment
There was a problem hiding this comment.
Although I thought of something like passing an object by const reference is much faster than passing by value while still ensuring that the original object won't get changed, it's okay from me. :-)
No description provided.