Skip to content

Commit

Permalink
mktime: simplify computation of average
Browse files Browse the repository at this point in the history
* time/mktime.c (ranged_convert): Use new time_t_avg function
instead of rolling our own (probably-slower) code.
  • Loading branch information
Paul Eggert committed May 23, 2012
1 parent ce73d68 commit 94c7d82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
2012-05-23 Paul Eggert <eggert@cs.ucla.edu>

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.
Expand Down
4 changes: 1 addition & 3 deletions time/mktime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 94c7d82

Please sign in to comment.