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

Remove sf::View::reset in favor of assignment operations #2942

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChrisThrasher
Copy link
Member

Description

It's rare that a type truly needs a .reset function. Copy/move assignment typically accomplishes the same thing with less code and is easier to maintain since it doesn't require updating your .reset() function as new data members are added.

To reset a type is conceptually the same thing as simply assigning from a newly constructed instance of the same type.

@coveralls
Copy link
Collaborator

coveralls commented Apr 13, 2024

Pull Request Test Coverage Report for Build 9145160170

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 55.704%

Totals Coverage Status
Change from base Build 9129910660: -0.01%
Covered Lines: 11486
Relevant Lines: 19539

💛 - Coveralls

@kimci86
Copy link
Contributor

kimci86 commented Apr 13, 2024

Worth noting that reset method was not doing the same as assigning a new constructed view because it was not changing viewport and scissor.

@ChrisThrasher
Copy link
Member Author

Worth noting that reset method was not doing the same as assigning a new constructed view because it was not changing viewport and scissor.

Good point. I wonder if that is an oversight or intentional. What could be the use case for resetting part of a view but not all of it?

@ChrisThrasher
Copy link
Member Author

ChrisThrasher commented May 13, 2024

Rebased on master. No changes made.

@ChrisThrasher
Copy link
Member Author

Worth noting that reset method was not doing the same as assigning a new constructed view because it was not changing viewport and scissor.

I did some digging in the commit history.

m_viewport was added in 7cc00085 which came after the addition of the reset function. It's feasible it was an oversight that reset was not amended to include this new data member.

A similar story is feasible for m_scissor which was added much more recently in #1451. It's so easy to forget to update this kind of reset function when adding more data members.

I think .reset() was never intended to skip those two data members.

It's rare that a type truly needs a .reset function. Copy/move
assignment typically accomplishes the same thing with less code
and is easier to maintain since it doesn't require updating your
.reset() function as new data members are added.

To reset a type is conceptually the same thing as simply assigning
from a newly constructed instance of the same type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Discussion
Development

Successfully merging this pull request may close these issues.

None yet

3 participants