On platforms where neither HAVE_GMTOFF nor HAVE___OFFSET is defined,
like Solaris, the function "get_offset" in apr/time/unix/time.c is a
bottleneck in time formatting.

On these platforms, get_offset ignores its argument; it really computes
the server's offset from GMT, normalized so that it's independent of
daylight savings.

The following patch caches the offset after it's first computed, so
that we don't have to compute it repeatedly.

--Brian

Index: apr/time/unix/time.c
===================================================================
RCS file: /home/cvspublic/apr/time/unix/time.c,v
retrieving revision 1.51
diff -r1.51 time.c
88,89c88,92
< {
< time_t t1 = time(0), t2 = 0;
---
> static apr_int32_t cached_offset = 100;
>
> if (cached_offset == 100) {
> struct timeval now;
> time_t t1, t2;
92a96,99
> gettimeofday(&now, NULL);
> t1 = now.tv_sec;
> t2 = 0;
>
101c108
< return (apr_int32_t) difftime(t1, t2) + (was_dst ? 3600 : 0);
---
> cached_offset = (apr_int32_t) difftime(t1, t2) + (was_dst ? 3600 : 0);
102a110
> return cached_offset;





Reply via email to