Skip to content

util: cache local GTimeZone

Christian Hergert requested to merge wip/chergert/localtime-fix into master

This ensures that we do not create a new GTimeZone with g_time_zone_new_local() repeatedly. Currently, that will cause GTimeZone to open(), mmap() and parse /etc/localtime while on the main thread.

We already track timezone changes, so we can cache this value and reuse it if we:

  1. Clear the cache when timezone changes
  2. Use the only GDateTime API available to us here, which means we imply the current time. But this is how environment.js uses the date and time anyway, so no loss.

We maintain the old form for plugin compatibility.

#2279

Edited by Christian Hergert

Merge request reports