View Issue Details

IDProjectCategoryView StatusLast Update
0035694LazarusLazUtilspublic2019-06-08 19:42
ReporterSerge AnvarovAssigned To 
PrioritynormalSeverityminorReproducibilityN/A
Status newResolutionopen 
Product Version2.1 (SVN)Product Build 
Target VersionFixed in Version 
Summary0035694: Micropatch of LazMethodList unit
DescriptionInlining the CompareMethods function and using it inside the unit.
TagsNo tags attached.
Fixed in Revision
LazTarget
Widgetset
Attached Files
  • LazMethodList.diff (1,501 bytes)
    Index: components/lazutils/lazmethodlist.pas
    ===================================================================
    --- components/lazutils/lazmethodlist.pas	(revision 61339)
    +++ components/lazutils/lazmethodlist.pas	(working copy)
    @@ -62,7 +62,7 @@
         property AllowDuplicates: boolean read FAllowDuplicates write SetAllowDuplicates; // default false, changed in Lazarus 1.3
       end;
     
    -function CompareMethods(const m1, m2: TMethod): boolean;
    +function CompareMethods(const m1, m2: TMethod): boolean; inline;
     
     
     implementation
    @@ -69,7 +69,11 @@
     
     function CompareMethods(const m1, m2: TMethod): boolean;
     begin
    +{$PUSH}  {$BOOLEVAL ON}
    +// With a full evaluation of the boolean expression the generated code will not
    +// contain conditional statements, which is more efficient on modern processors
       Result:=(m1.Code=m2.Code) and (m1.Data=m2.Data);
    +{$POP}
     end;
     
     { TMethodList.TItemsEnumerator }
    @@ -134,8 +138,7 @@
           j:=i+1;
           while j<FCount do
           begin
    -        if (FItems[i].Code=FItems[j].Code)
    -        and (FItems[i].Data=FItems[j].Data) then
    +        if CompareMethods(FItems[i], FItems[j]) then
               Delete(j)
             else
               inc(j);
    @@ -207,8 +210,8 @@
       if Self<>nil then begin
         Result:=FCount-1;
         while Result>=0 do begin
    -      if (FItems[Result].Code=AMethod.Code)
    -      and (FItems[Result].Data=AMethod.Data) then exit;
    +      if CompareMethods(FItems[Result], AMethod) then
    +        Exit;
           dec(Result);
         end;
       end else
    
    LazMethodList.diff (1,501 bytes)

Activities

Serge Anvarov

2019-06-08 19:42

reporter  

LazMethodList.diff (1,501 bytes)
Index: components/lazutils/lazmethodlist.pas
===================================================================
--- components/lazutils/lazmethodlist.pas	(revision 61339)
+++ components/lazutils/lazmethodlist.pas	(working copy)
@@ -62,7 +62,7 @@
     property AllowDuplicates: boolean read FAllowDuplicates write SetAllowDuplicates; // default false, changed in Lazarus 1.3
   end;
 
-function CompareMethods(const m1, m2: TMethod): boolean;
+function CompareMethods(const m1, m2: TMethod): boolean; inline;
 
 
 implementation
@@ -69,7 +69,11 @@
 
 function CompareMethods(const m1, m2: TMethod): boolean;
 begin
+{$PUSH}  {$BOOLEVAL ON}
+// With a full evaluation of the boolean expression the generated code will not
+// contain conditional statements, which is more efficient on modern processors
   Result:=(m1.Code=m2.Code) and (m1.Data=m2.Data);
+{$POP}
 end;
 
 { TMethodList.TItemsEnumerator }
@@ -134,8 +138,7 @@
       j:=i+1;
       while j<FCount do
       begin
-        if (FItems[i].Code=FItems[j].Code)
-        and (FItems[i].Data=FItems[j].Data) then
+        if CompareMethods(FItems[i], FItems[j]) then
           Delete(j)
         else
           inc(j);
@@ -207,8 +210,8 @@
   if Self<>nil then begin
     Result:=FCount-1;
     while Result>=0 do begin
-      if (FItems[Result].Code=AMethod.Code)
-      and (FItems[Result].Data=AMethod.Data) then exit;
+      if CompareMethods(FItems[Result], AMethod) then
+        Exit;
       dec(Result);
     end;
   end else
LazMethodList.diff (1,501 bytes)

Issue History

Date Modified Username Field Change
2019-06-08 19:42 Serge Anvarov New Issue
2019-06-08 19:42 Serge Anvarov File Added: LazMethodList.diff