* in SysUtils.DecodeDate(), cast the result of trunc() to longint (trunc

normally returns int64 in FPC), before performing any further calculations -
  the result always fits in a longint (the date is range checked against
  MaxDateTime and that is well within longint limits). This generates faster
  code on non 64-bit targets and also fixes i8086 compilation, which previously
  failed on register allocation on this function.

git-svn-id: trunk@33946 -
This commit is contained in:
nickysn 2016-06-10 19:39:44 +00:00
parent cf6c7a0a1d
commit c205cb03c8

View File

@ -167,7 +167,7 @@ begin
if Date>MaxDateTime then
Date:=MaxDateTime;
// Raise EConvertError.CreateFmt('%f is not a valid TDatetime encoding, maximum value is %f.',[Date,MaxDateTime]);
j := pred((Trunc(System.Int(Date)) + 693900) SHL 2);
j := pred((longint(Trunc(System.Int(Date))) + 693900) SHL 2);
ly:= j DIV 146097;
j:= j - 146097 * cardinal(ly);
ld := j SHR 2;