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:
ooonea 2026-04-19 21:56:36 +02:00
parent 1b815ea3fe
commit 8432e1dcdc
No known key found for this signature in database
GPG key ID: 3CD106C3A25275AD

View file

@ -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