mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-23 14:00:40 +02:00
gmain: Remove an expensive function call from ABS() arguments
It’s possible that `ABS()` will evaluate its argument more than once, so it’s best to not call expensive functions as the argument expression. Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
parent
c2c9db0629
commit
fe7b5132f6
@ -5055,9 +5055,14 @@ g_timeout_set_expiration (GTimeoutSource *timeout_source,
|
||||
if (!session_bus_address)
|
||||
session_bus_address = g_getenv ("HOSTNAME");
|
||||
if (session_bus_address)
|
||||
timer_perturb = ABS ((gint) g_str_hash (session_bus_address)) % 1000000;
|
||||
{
|
||||
int hash = g_str_hash (session_bus_address);
|
||||
timer_perturb = ABS (hash) % 1000000;
|
||||
}
|
||||
else
|
||||
timer_perturb = 0;
|
||||
{
|
||||
timer_perturb = 0;
|
||||
}
|
||||
}
|
||||
|
||||
expiration = current_time + (guint64) timeout_source->interval * 1000 * 1000;
|
||||
|
Loading…
x
Reference in New Issue
Block a user