-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Simplify/optimize battery util on linux #2287
Conversation
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.
The uncontrollable side-effects caused by redefining symbols in the header file are not acceptable. Revert those changes and replace with a forward declaration.
ebe77cc
to
25df965
Compare
I'm not convinced that the code gets easier to follow by using deeply nested if blocks. Safely initializing the members with invalid/unknown default values and returning as soon as possible when you are not able to read the required values is simpler and more robust. |
7a21b47
to
4d33dde
Compare
4d33dde
to
c2602c9
Compare
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.
Much easier to read now. Just some minor remarks.
The |
c2602c9
to
f234dc6
Compare
Thank you for taking care of these little performance details that easily slip through unnoticed! LGTM |
I discovered an interesting side effect of the 'create the upower client once' change. |
Stopping the dbus service kills my whole desktop. When stopping the upower service I don't experience any issues. |
Instead of looping over a copy of the device objects, get the appropriate device directly via
up_client_get_display_device()
.Checking
is-present
makes sure that hot pluggable batteries are handled correctly.The upower client is only created once in the class constructor.
(There was a comment about this in the code, but I could not reproduce the issue)
Note that this removes support for upower < 0.99.0. (It should still work on Xenial)