зеркало из https://github.com/mozilla/pjs.git
Replace some ternary expressions
step += (InLeapYear(t) ? 29 : 28); with the form if (InLeapYear(t)) step += 29; else step += 28; to work around an apparent JRE bug in which the code always returns 28.
This commit is contained in:
Родитель
54eeb4f424
Коммит
98328c4bf4
|
@ -222,7 +222,14 @@ public class NativeDate extends ScriptableObject {
|
|||
|
||||
if (d < (step = 31))
|
||||
return 0;
|
||||
step += (InLeapYear(t) ? 29 : 28);
|
||||
|
||||
// Originally coded as step += (InLeapYear(t) ? 29 : 28);
|
||||
// but some jits always returned 28!
|
||||
if (InLeapYear(t))
|
||||
step += 29;
|
||||
else
|
||||
step += 28;
|
||||
|
||||
if (d < step)
|
||||
return 1;
|
||||
if (d < (step += 31))
|
||||
|
@ -250,11 +257,17 @@ public class NativeDate extends ScriptableObject {
|
|||
int d, step, next;
|
||||
|
||||
d = DayWithinYear(t);
|
||||
|
||||
if (d <= (next = 30))
|
||||
return d + 1;
|
||||
step = next;
|
||||
next += (InLeapYear(t) ? 29 : 28);
|
||||
|
||||
// Originally coded as next += (InLeapYear(t) ? 29 : 28);
|
||||
// but some jits always returned 28!
|
||||
if (InLeapYear(t))
|
||||
next += 29;
|
||||
else
|
||||
next += 28;
|
||||
|
||||
if (d <= next)
|
||||
return d - step;
|
||||
step = next;
|
||||
|
@ -285,6 +298,10 @@ public class NativeDate extends ScriptableObject {
|
|||
if (d <= (next += 30))
|
||||
return d - step;
|
||||
step = next;
|
||||
|
||||
System.err.println("step is " + step);
|
||||
System.err.println("result is " + (d - step));
|
||||
|
||||
return d - step;
|
||||
}
|
||||
|
||||
|
|
|
@ -222,7 +222,14 @@ public class NativeDate extends ScriptableObject {
|
|||
|
||||
if (d < (step = 31))
|
||||
return 0;
|
||||
step += (InLeapYear(t) ? 29 : 28);
|
||||
|
||||
// Originally coded as step += (InLeapYear(t) ? 29 : 28);
|
||||
// but some jits always returned 28!
|
||||
if (InLeapYear(t))
|
||||
step += 29;
|
||||
else
|
||||
step += 28;
|
||||
|
||||
if (d < step)
|
||||
return 1;
|
||||
if (d < (step += 31))
|
||||
|
@ -250,11 +257,17 @@ public class NativeDate extends ScriptableObject {
|
|||
int d, step, next;
|
||||
|
||||
d = DayWithinYear(t);
|
||||
|
||||
if (d <= (next = 30))
|
||||
return d + 1;
|
||||
step = next;
|
||||
next += (InLeapYear(t) ? 29 : 28);
|
||||
|
||||
// Originally coded as next += (InLeapYear(t) ? 29 : 28);
|
||||
// but some jits always returned 28!
|
||||
if (InLeapYear(t))
|
||||
next += 29;
|
||||
else
|
||||
next += 28;
|
||||
|
||||
if (d <= next)
|
||||
return d - step;
|
||||
step = next;
|
||||
|
@ -285,6 +298,10 @@ public class NativeDate extends ScriptableObject {
|
|||
if (d <= (next += 30))
|
||||
return d - step;
|
||||
step = next;
|
||||
|
||||
System.err.println("step is " + step);
|
||||
System.err.println("result is " + (d - step));
|
||||
|
||||
return d - step;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче