diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-01-10 16:57:53 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-01-10 18:49:21 +0100 |
commit | f18f4818ed2c992aa9b7b91c74bb9ce7cc1bc745 (patch) | |
tree | da9d7e335d7f6daeca3360820ea2013663f8a769 /sfeed_update | |
parent | c1b44cf790f8090ff25a2ff268c3f7a8d53e1bcf (diff) |
optimize converting UNIX timestamp to localtime
Make a huge difference (cuts the time in half to process the same amount of
lines) on atleast glibc 2.30 on Void Linux. Seems to make no difference on
OpenBSD.
- This removes atleast one heap allocation per line (checked with valgrind).
This is because glibc will strdup() the environment variable $TZ and free it
each time, which is pointless here and wasteful.
- localtime_r does not require to set the variables like tzname.
In glibc-2.30/time/tzset.c in __tz_convert is the following code and comment:
/* Update internal database according to current TZ setting.
POSIX.1 8.3.7.2 says that localtime_r is not required to set tzname.
This is a good idea since this allows at least a bit more parallelism. */
tzset_internal (tp == &_tmbuf && use_localtime);
This makes it always tzset() and inspect the environment $TZ etc. While with
localtime_r it will only initialize it once:
static void tzset_internal (int always) {
[...]
if (is_initialized && !always)
return;
Diffstat (limited to 'sfeed_update')
0 files changed, 0 insertions, 0 deletions