mirror of
https://github.com/erpalma/throttled.git
synced 2026-04-21 06:03:56 +00:00
Efficiency: drop the duplicate is_on_battery call in power_thread
In polling mode, power['source'] is already set from is_on_battery at the top of each iteration, so the HWP check was calling is_on_battery a second time for the same value. Replace the whole dbus-vs-polling branch with `power['source'] == 'AC'`, which is correct for both methods and avoids the extra glob/file read (and a fallback DBus round-trip). Signed-off-by: ooonea <35407790+ooonea@users.noreply.github.com>
This commit is contained in:
parent
1b815ea3fe
commit
8432e1dcdc
1 changed files with 1 additions and 8 deletions
|
|
@ -787,14 +787,7 @@ def power_thread(config, regs, exit_event, cpuid):
|
|||
wait_t = config.getfloat(power['source'], 'Update_Rate_s')
|
||||
enable_hwp_mode = config.getboolean('AC', 'HWP_Mode', fallback=None)
|
||||
# set HWP less frequently. Just to be safe since (e.g.) TLP might reset this value
|
||||
if (
|
||||
enable_hwp_mode
|
||||
and next_hwp_write <= time()
|
||||
and (
|
||||
(power['method'] == 'dbus' and power['source'] == 'AC')
|
||||
or (power['method'] == 'polling' and not is_on_battery(config))
|
||||
)
|
||||
):
|
||||
if enable_hwp_mode and next_hwp_write <= time() and power['source'] == 'AC':
|
||||
set_hwp(enable_hwp_mode)
|
||||
next_hwp_write = time() + HWP_INTERVAL
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue