]> granicus.if.org Git - php/commitdiff
MFB: Optimize out a loop
authorIlia Alshanetsky <iliaa@php.net>
Wed, 6 Jun 2007 22:58:53 +0000 (22:58 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 6 Jun 2007 22:58:53 +0000 (22:58 +0000)
ext/date/php_date.c

index 592577be18f38b4360e5c8593cb46b2e6dfaaaa5..ea70ec3562a37a7e018a9b6172f40cfc5b1292dd 100644 (file)
@@ -2484,12 +2484,13 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
                RETURN_LONG(calc_sunset ? set : rise);
        }
        N = (calc_sunset ? h_set : h_rise) + gmt_offset;
-       while (N > 24) {
-               N -= 24;
-       }
-       while (N < 0) {
-               N += 24;
+
+       if (N > 24) {
+               N %= 24;
+       } else if (N < 0) {
+               N = N % 24 + 24;
        }
+
        switch (retformat) {
                case SUNFUNCS_RET_STRING:
                        sprintf(retstr, "%02d:%02d", (int) N, (int) (60 * (N - (int) N)));