View Issue Details

IDProjectCategoryView StatusLast Update
0020657LazarusOtherpublic2011-11-09 16:47
ReporterbarloneAssigned ToFelipe Monteiro de Carvalho 
PrioritynormalSeveritytrivialReproducibilityN/A
Status closedResolutionfixed 
Product Version0.9.31 (SVN)Product Build 
Target VersionFixed in Version0.9.31 (SVN) 
Summary0020657: small refactoring of lazutf8sysutils.pas
DescriptionChanges eliminate some compiler warnings and produce more compact code.
TagsNo tags attached.
Fixed in Revision33437
LazTarget-
Widgetset
Attached Files
  • lazutf8sysutils.pas.patch (1,153 bytes)
    Index: lazutf8sysutils.pas
    ===================================================================
    --- lazutf8sysutils.pas	(revision 33415)
    +++ lazutf8sysutils.pas	(working copy)
    @@ -32,7 +32,7 @@
     end;
     
     // GetTickCount64 is better, but we need to check the Windows version to use it
    -function GetTickCount: Int64;
    +function GetTickCount: Int64; inline;
     begin
       Result := Windows.GetTickCount();
     end;
    @@ -46,7 +46,7 @@
       D1   = 146097;
       D2   =1721119;
     
    -Procedure JulianToGregorian(JulianDN:LongInt;Var Year,Month,Day:Word);
    +Procedure JulianToGregorian(JulianDN:LongInt;out Year,Month,Day:Word);
     Var
       YYear,XYear,Temp,TempMonth : LongInt;
     Begin
    @@ -69,7 +69,7 @@
     
     
     
    -Procedure EpochToLocal(epoch:longint;var year,month,day,hour,minute,second:Word);
    +Procedure EpochToLocal(epoch:longint;out year,month,day,hour,minute,second:Word);
     {
       Transforms Epoch time into local time (hour, minute,seconds)
     }
    @@ -106,7 +106,7 @@
     end;
     {$else}
     // Not Windows and not UNIX, so just write the most trivial code until we have something besser:
    -function NowUTC: TDateTime;
    +function NowUTC: TDateTime; inline;
     begin
       Result := Now;
     end;
    

Activities

2011-11-09 12:07

 

lazutf8sysutils.pas.patch (1,153 bytes)
Index: lazutf8sysutils.pas
===================================================================
--- lazutf8sysutils.pas	(revision 33415)
+++ lazutf8sysutils.pas	(working copy)
@@ -32,7 +32,7 @@
 end;
 
 // GetTickCount64 is better, but we need to check the Windows version to use it
-function GetTickCount: Int64;
+function GetTickCount: Int64; inline;
 begin
   Result := Windows.GetTickCount();
 end;
@@ -46,7 +46,7 @@
   D1   = 146097;
   D2   =1721119;
 
-Procedure JulianToGregorian(JulianDN:LongInt;Var Year,Month,Day:Word);
+Procedure JulianToGregorian(JulianDN:LongInt;out Year,Month,Day:Word);
 Var
   YYear,XYear,Temp,TempMonth : LongInt;
 Begin
@@ -69,7 +69,7 @@
 
 
 
-Procedure EpochToLocal(epoch:longint;var year,month,day,hour,minute,second:Word);
+Procedure EpochToLocal(epoch:longint;out year,month,day,hour,minute,second:Word);
 {
   Transforms Epoch time into local time (hour, minute,seconds)
 }
@@ -106,7 +106,7 @@
 end;
 {$else}
 // Not Windows and not UNIX, so just write the most trivial code until we have something besser:
-function NowUTC: TDateTime;
+function NowUTC: TDateTime; inline;
 begin
   Result := Now;
 end;

Felipe Monteiro de Carvalho

2011-11-09 16:26

developer   ~0053957

I applied the part about the compiler warnings, although I think this is not really something useful. This code for example comes directly from the RTL, so I think that the amount of places where var is used as out is immense, and refactoring all of them just to remove warnings is not something sensible. This particular warning does not looks something relevant.

I rejected the part which converts the routines as inlines because that's just not in like with how the rest of the code is implemented. The speed gain from inline here is almost zero, the really expensive operations are the syscalls, and inline would bring an executable size increase.

barlone

2011-11-09 16:47

reporter   ~0053958

Thank for comments, Felipe. I see great benefit of changes from `var` to `out` in more intuitive understanding of function declaration and exclusion errors within function. The greater the number of warnings interferes see the really important issues.

Issue History

Date Modified Username Field Change
2011-11-09 12:07 barlone New Issue
2011-11-09 12:07 barlone File Added: lazutf8sysutils.pas.patch
2011-11-09 16:08 Felipe Monteiro de Carvalho Status new => assigned
2011-11-09 16:08 Felipe Monteiro de Carvalho Assigned To => Felipe Monteiro de Carvalho
2011-11-09 16:26 Felipe Monteiro de Carvalho Fixed in Revision => 33437
2011-11-09 16:26 Felipe Monteiro de Carvalho LazTarget => -
2011-11-09 16:26 Felipe Monteiro de Carvalho Status assigned => resolved
2011-11-09 16:26 Felipe Monteiro de Carvalho Fixed in Version => 0.9.31 (SVN)
2011-11-09 16:26 Felipe Monteiro de Carvalho Resolution open => fixed
2011-11-09 16:26 Felipe Monteiro de Carvalho Note Added: 0053957
2011-11-09 16:47 barlone Status resolved => closed
2011-11-09 16:47 barlone Note Added: 0053958