From: Paul Eggert Date: Fri, 16 Mar 2012 10:15:57 +0000 (-0700) Subject: mktime: simplify computation of average X-Git-Tag: upstream/2.20~3824 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94c7d826c97ec1ae6ced9f83fe1fe6cfcc235edb;p=platform%2Fupstream%2Flinaro-glibc.git mktime: simplify computation of average * time/mktime.c (ranged_convert): Use new time_t_avg function instead of rolling our own (probably-slower) code. --- diff --git a/ChangeLog b/ChangeLog index 066a6da..e795eca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2012-05-23 Paul Eggert + mktime: simplify computation of average + * time/mktime.c (ranged_convert): Use new time_t_avg function + instead of rolling our own (probably-slower) code. + mktime: do not assume signed right shift propagates sign bit * time/mktime.c (isdst_differ): New static function. (__mktime_internal): No need to normalize tm_isdst now. diff --git a/time/mktime.c b/time/mktime.c index dd7daaf..f4d9cf1 100644 --- a/time/mktime.c +++ b/time/mktime.c @@ -319,9 +319,7 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), they differ by 1. */ while (bad != ok + (bad < 0 ? -1 : 1)) { - time_t mid = *t = (bad < 0 - ? bad + ((ok - bad) >> 1) - : ok + ((bad - ok) >> 1)); + time_t mid = *t = time_t_avg (ok, bad); r = convert (t, tp); if (r) ok = mid;