-
-
Notifications
You must be signed in to change notification settings - Fork 688
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
General cleanup in hyprland/workspaces #2592
Conversation
@MightyPlaza Yep, that's the next step, for another PR :) |
just wanted to point it out since most code for persistent workspaces can be removed now |
It's just a personal preference, but if a "global" will only be used in one scope, I find it better to define it as a
Given the above reasons, I'd say I don't understand why one would prefer a global variable over a scoped |
Here are the reasons I thought it was strange:
But your reasons are more logical in this case as it's only used in one place. I changed it back. |
Just out of interest, could there be a (tiny) runtime performance difference when defining a static variable inside the function it is used in, if that function is called repeatedly? We're statically defining the WINDOW_CREATION_TIMEOUT variable in the update() function, which is called on every event. When running, does it check every iteration whether the static variable was defined yet? This obviously would make zero noticable difference in real-world usage, but I'm interested in how that works. |
From the compiler explorer link, they should be compiled down to the same thing even with
#include <cstdio>
const int A = 10;
void with_global() {
printf("A=%d\n", A);
}
void with_scoped() {
static const int B = 20;
printf("B=%d\n", B);
} .LC0:
.string "A=%d\n"
with_global():
push rbp
mov rbp, rsp
mov esi, 10
mov edi, OFFSET FLAT:.LC0
mov eax, 0
call printf
nop
pop rbp
ret
.LC1:
.string "B=%d\n"
with_scoped():
push rbp
mov rbp, rsp
mov esi, 20
mov edi, OFFSET FLAT:.LC1
mov eax, 0
call printf
nop
pop rbp
ret The only real difference is the scopes in which the compiler will allow you to use the variable |
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.
Great PR, and I look forward to the clang-tidy PR, too!
Just made some more changes, could you re-review? Thanks! |
@Alexays ready to merge :) |
void on_workspace_destroyed(std::string const& payload); | ||
void on_workspace_created(std::string const& payload); | ||
void on_workspace_moved(std::string const& payload); | ||
void on_workspace_renamed(std::string const& payload); |
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.
Thank you for doing this... I didn't like how busy that method was.
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.
This was also a hint by clang-tidy: it shows a warning if a function is too complex. Another reason to add it to the repo :)
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.
Forgot to submit the review yesterday, my apologies!
Thanks! |
Did some cleanup in hyprland/workspaces:
Put the WINDOW_CREATION_TIMEOUT variable in an anonymous namespace (it used to be statically defined inside the function it was used in, I don't understand why?)On a related note, I also started a discussion here about adding a clang-tidy file to the repo: #2591. I'd love to hear your thoughts on this.
CC: @Syndelis @khaneliman @Anakael @MightyPlaza