-
Notifications
You must be signed in to change notification settings - Fork 208
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
Switch to C++17 and use string_view #252
Conversation
8aabc45
to
29171b1
Compare
bddacf4
to
012c82b
Compare
6396dec
to
22594b5
Compare
22594b5
to
ddccf13
Compare
@psi29a maybe you can verify this compiles on Mac? |
I can check that |
We an also setup github actions to do that for us. :) |
That would be great, since travis-ci is broken now |
@Assumeru there are few review comments above before we can merge this |
And thank you for you work, glad to see so big and good PR |
The thing about cmake policies AnyOldName3 mentioned or the commits you added?
Thanks for even being willing to entertain the notion of a 2k line PR 😅 Once this is merged I'll probably end up submitting some more to get rid of a few compilation warnings (implicit casts, c-style casts) and maybe to employ unique_ptr so we can eliminate a few destructors. |
No, there are my review comments above. The only critical one is about eventClipboardChanged |
I'm waiting for this PR before pushing my massive changes, so don't rush into doing that. |
I'm not seeing any other comments. Did you leave them as a draft? |
@Assumeru my bad. sorry |
I don't have the button to unresolve #252 (comment) so I'm making another top-level comment so my last post has some visibility. I don't think the thread should have been resolved. |
d03ea63
to
66492c2
Compare
@Assumeru Done |
Awesome. |
@@ -357,7 +358,7 @@ namespace MyGUI | |||
Widget* _getClientWidget(); | |||
const Widget* _getClientWidget() const; | |||
|
|||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value); | |||
virtual void setPropertyOverride(std::string_view _key, std::string_view _value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A virtual
means that the client applications may derive from class and override a virtual method. When you change the signature of virtual method, client applications which override it will stop to compile.
So when you modify a library's public API, you usually keep both old and new API, but mark old API as deprecated. Later you remove deprecated API as a part of cleanup for major release and post a migration guide. In this case developers of client applications have enough time to migrate their code to upstream API. For example, API from Qt4 was deprecated in Qt5 and removed only in Qt6.
So far MyGUI 3.4.3 is incompatible with MyGUI 3.4.2 and earlier versions, but release changelog does not directly contain any info about it.
As mentioned in #251.
This PR attempts to reduce the number of superfluous string allocations in MyGUI. Mostly by employing string_view almost everywhere, but also by fixing a few places that copied a (return) value instead of taking it by reference, and (in places I spotted the issue) by preventing redundant UString->string->UString conversion chains.
Some aspects of the API where left as
const std::string&
, mostly the ones that ended up calling Ogre functions taking arguments of that type. It might be worth changing more of those over to string_view in the future though such a change would necessarily favour the other rendering targets over Ogre in terms of performance -- minor though the difference might be.This is a pretty big change with regard to backwards compatibility. Upgrading shouldn't be particularly hard, it wasn't for OpenMW.
I've tested compilation on Windows 10 / MSVC and Ubuntu 22 / Clang 14.