Skip to content

Various fixes#307

Merged
texus merged 5 commits intotexus:1.xfrom
jjuhl:various-fixes
Feb 2, 2026
Merged

Various fixes#307
texus merged 5 commits intotexus:1.xfrom
jjuhl:various-fixes

Conversation

@jjuhl
Copy link
Contributor

@jjuhl jjuhl commented Feb 1, 2026

Hi Texus

Here's another small batch of small fixes/cleanups for you to consider.

Kind regards
Jesper Juhl

jjuhl added 5 commits February 1, 2026 20:11
For improved readability.
Follow-up to commit 29a96fa
Neither the pointer value nor the pointed-to data should ever change.
It makes the code harder to read and the compiler will optimize out
the intermediate temporary variable anyway.
Copy link
Owner

@texus texus left a comment

Choose a reason for hiding this comment

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

The std::move in BackendGui::handleEvent isn't pointless here, is it? The local mouseMoveEvent variable isn't used anymore afterwards and the handleEvent function takes the event by value?

@jjuhl
Copy link
Contributor Author

jjuhl commented Feb 2, 2026

I'm pretty sure the std::move is pointless.
Event doesn't have a move constructor nor a move assignment operator, so casting the passed in "mouseMoveEvent" to a xvalue via std::move can't really do anything. And the Event struct also looks like it's almost trivially copyable (to me - I could be wrong).

Also, if I compile the file with g++ and -O2 to like this:
g++ -c -m64 -O2 -std=c++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -fdiagnostics-color=always -Wall -Wextra -Wshadow -Wsign-conversion -Wfloat-conversion -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -Wnull-dereference -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -Wsuggest-override -Winvalid-pch -I/home/jj/src/TGUI/include -DTGUI_DYNAMIC -DTGUI_EXPORTS -x c++ /home/jj/src/TGUI/src/Backend/Window/BackendGui.cpp
and then compare the result before and after the change I get this:

before:
$ size ./BackendGui.o
text data bss dec hex filename
21368 336 0 21704 54c8 ./BackendGui.o
after:
$ size ./BackendGui.o
text data bss dec hex filename
21368 336 0 21704 54c8 ./BackendGui.o

and if I then do
$ objdump -C -d ./BackendGui.o
the generated assembly for BackendGui::handleEvent is also identical in both cases.

@texus
Copy link
Owner

texus commented Feb 2, 2026

You are absolutely right. I was only looking at the calling code and at the function signature, I didn't think about the fact that Event was a trivial type.

@texus texus merged commit 9452539 into texus:1.x Feb 2, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants