Skip to content
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

Take args by const reference where useful. #58

Merged
merged 5 commits into from
Nov 1, 2019
Merged

Take args by const reference where useful. #58

merged 5 commits into from
Nov 1, 2019

Conversation

de-vri-es
Copy link
Contributor

This PR does a couple of things:

  • It removes trailing whitespace.
  • It takes arguments by const & where useful (like std::string or objects containing strings).
  • It makes the project pass -Wall -Wextra -Wpedantic without warnings:
    • A loop counter as signed integer caused signed/unsigned comparison.
    • TriBool had a manual copy assignment operator, but not a manual copy constructor.

The arguments by const & is the most important part of the PR, as it can lead to actual performance improvement.

Note that in some cases, for constructors, taking objects by value and moving them into members would be even more efficient, but that would mean requiring C++11. It looked like the project doesn't require that yet, so I decided not to go for that.

@de-vri-es
Copy link
Contributor Author

Just noticed: this would fix #13.

@gavanderhoorn
Copy link
Member

Thanks for the PR 👍 . Unfortunately reviewing and merging it is going to take some time, as both me and @jontje have a very busy few weeks ahead of us.

Copy link
Contributor

@jontje jontje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice job! Greatly appreciated, this has been pending for quite some time.

All my tests pass, and I have added a few minor code changes concerning line lengths. And if you resolve the branch conflicts, then I will approve the PR.

FYI, the code style of this library has primarily been based on the ROS C++ Style Guide, which specify a maximum line length of 120 characters. I don’t think this is mentioned anywhere, so it’s impossible for you to know.

src/rws_client.cpp Outdated Show resolved Hide resolved
src/rws_state_machine_interface.cpp Outdated Show resolved Hide resolved
src/rws_state_machine_interface.cpp Outdated Show resolved Hide resolved
src/rws_state_machine_interface.cpp Outdated Show resolved Hide resolved
de-vri-es and others added 5 commits October 31, 2019 20:57
A class should either define both a manual copy constructor and copy
assignment operator, or neither. In this case, the implementation was
equivalent to the implicit version already created by the compiler, so
the operator could be removed without problem.
Co-Authored-By: jontje <jontje@users.noreply.github.com>
@de-vri-es
Copy link
Contributor Author

Thanks for the review. I applied your suggestions and rebased on current master.

FYI, the code style of this library has primarily been based on the ROS C++ Style Guide, which specify a maximum line length of 120 characters. I don’t think this is mentioned anywhere, so it’s impossible for you to know.

I generally try to guess style rules from the surrounding code, but I may accidentally revert to my own preferences now and then. Good thing the review caught it :)

Copy link
Contributor

@jontje jontje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving according to my previous comment at #58 (review).

Thanks! 👍

@jontje jontje merged commit 719a34b into ros-industrial:master Nov 1, 2019
@jontje
Copy link
Contributor

jontje commented Nov 1, 2019

I generally try to guess style rules from the surrounding code, but I may accidentally revert to my own preferences now and then. Good thing the review caught it :)

No worries, and I try to at least be semi-pedantic when reviewing;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants