close
Skip to content

Make 'Rect' a 'constexpr' class#1909

Merged
vittorioromeo merged 1 commit into
masterfrom
feature/make_rect_constexpr
Dec 18, 2021
Merged

Make 'Rect' a 'constexpr' class#1909
vittorioromeo merged 1 commit into
masterfrom
feature/make_rect_constexpr

Conversation

@vittorioromeo

Copy link
Copy Markdown
Member

Description

This PR turns sf::Rect into a constexpr-friendly class, and also provides a few more improvements:

  • Removes dependency on <algorithm> from a widely used header, improving compilation time
    • Some other headers were relying on transitive includes from Rect.hpp, so they have been fixed
  • Removes unnecessary sf:: qualification when referring to Vector inside Rect

Tasks

  • Tested on Linux
  • Tested on Windows
  • Tested on macOS
  • Tested on iOS
  • Tested on Android

How to test this PR?

CI.

@Bromeon

Bromeon commented Dec 16, 2021

Copy link
Copy Markdown
Member

Maybe before commenting on constexpr for Rect and Vertex in particular:

We have guy who put in all the effort at the beginning of the year in #1741 and even split the commits by class. I know his PR might not be ready-to-use now, but I'm not too happy about telling him we still need to discuss the topic, and then later rewriting everything without him, with no single credit. This could make him reconsider future contributions, and rightfully so.

What we could do is take his commits (under his author), perform the necessary changes and add Signed-off-by: clause in the commit message.

@vittorioromeo

Copy link
Copy Markdown
Member Author

Maybe before commenting on constexpr for Rect and Vertex in particular:

We have guy who put in all the effort at the beginning of the year in #1741 and even split the commits by class. I know his PR might not be ready-to-use now, but I'm not too happy about telling him we still need to discuss the topic, and then later rewriting everything without him, with no single credit. This could make him reconsider future contributions, and rightfully so.

What we could do is take his commits (under his author), perform the necessary changes and add Signed-off-by: clause in the commit message.

Thanks for bringing this up, I do believe it is an important thing to consider.

I'm totally happy for @fgallegosalido to take the credit for these changes, which are pretty much the same as the ones he contributed back in #1741. I am not sure what the easiest way to achieve that would be, but I also don't really feel like dealing with git cherry-picking and rebasing before we can merge these changes in.

Is it possible to force-change the author of a commit? I'd be fine with changing the authorship of my commit to @fgallegosalido. Alternatively, if he is fine with it, I'd also propose simply adding "Originally contributed to @fgallegosalido" to these commits or something alongside those lines to avoid any git-related pain/maintenance.

Let me know what you think.

@Bromeon

Bromeon commented Dec 16, 2021

Copy link
Copy Markdown
Member

An alternative would be a Co-authored-by: clause in the commit message. The semantics are a bit different: this means that multiple developers authored a change, while Signed-off-by: means that one person authored it and another "signed it off", i.e. adjusted it to latest master, made minor corrections etc. "Sign off" could also have the literal meaning of just approving it.

Maybe @fgallegosalido sees this himself and can tell us what he prefers? Otherwise I'd say we go with one of those two clauses (they are "official" in the sense that GitHub and other tools can parse them).

@fgallegosalido

Copy link
Copy Markdown
Contributor

Oh, no worries from my part. I'm totally fine with not being the final author of those commits. If you want to put me as co-author is fine, but I have no problem at all if you don't.

I am already happy that you acknowledge my contributions, as I almost completely forgot about this matter.

I think closing my pull request is fine and the one by @vittorioromeo should be accepted one, as it is more up-to-date.

@Bromeon

Bromeon commented Dec 16, 2021

Copy link
Copy Markdown
Member

Thank you @fgallegosalido!

@vittorioromeo: In that case, it's probably easiest if you leave this PR as-is and simply change the commit message to include:

Co-authored-by: fgallegosalido <fgallegosalido@gmail.com>

I'll try to review the technical parts later today 🙂

@vittorioromeo vittorioromeo force-pushed the feature/make_rect_constexpr branch from 66421d6 to 781a364 Compare December 16, 2021 16:06
@vittorioromeo

Copy link
Copy Markdown
Member Author

Added! :)

@fgallegosalido

Copy link
Copy Markdown
Contributor

I also think we can close #1741, as these wave of changes are much more complete than what I did back then. Thank you @vittorioromeo for your contributions! We all wanted SFML to be modernized ^.^

Comment thread include/SFML/Graphics/Rect.inl
Comment thread include/SFML/Graphics/Rect.inl
@vittorioromeo

Copy link
Copy Markdown
Member Author

@Bromeon: ping :)

@vittorioromeo vittorioromeo merged commit cfeb765 into master Dec 18, 2021
@eXpl0it3r eXpl0it3r deleted the feature/make_rect_constexpr branch December 18, 2021 16:34
Comment on lines +78 to +80
// Not using 'std::min' and 'std::max' to avoid depending on '<algorithm>'
const auto min = [](T a, T b){ return (a < b) ? a : b; };
const auto max = [](T a, T b){ return (a < b) ? b : a; };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

image

lol (not upset, just having a laugh)

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

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants