Recent

Author Topic: [SOLVED] Duplicate code removal in lcl/controls.pp  (Read 2013 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 407
[SOLVED] Duplicate code removal in lcl/controls.pp
« on: April 03, 2023, 01:30:48 pm »
procedure TControlChildSizing.Assign(Source: TPersistent); has useless duplication of the following code:
Code: Pascal  [Select][+][-]
  1. FEnlargeHorizontal:=SrcSizing.EnlargeHorizontal;
  2.     FEnlargeVertical:=SrcSizing.EnlargeVertical;
  3.     FShrinkHorizontal:=SrcSizing.ShrinkHorizontal;
  4.     FShrinkVertical:=SrcSizing.ShrinkVertical;
   
function TControlChildSizing.IsEqual(Sizing: TControlChildSizing): boolean; has useless duplication of the following code:
Code: Pascal  [Select][+][-]
  1. (FEnlargeHorizontal=Sizing.EnlargeHorizontal)
  2.       and (FEnlargeVertical=Sizing.EnlargeVertical)
  3.       and (FShrinkHorizontal=Sizing.ShrinkHorizontal)
  4.       and (FShrinkVertical=Sizing.ShrinkVertical)
  5.  
     
The following patch removes the duplicate code.

Code: Pascal  [Select][+][-]
  1. diff --git a/lcl/controls.pp b/lcl/controls.pp
  2. index 397076a37a..172b2e1e7f 100644
  3. --- a/lcl/controls.pp
  4. +++ b/lcl/controls.pp
  5. @@ -4033,10 +4033,6 @@ begin
  6.      SrcSizing:=TControlChildSizing(Source);
  7.      if IsEqual(SrcSizing) then exit;
  8.  
  9. -    FEnlargeHorizontal:=SrcSizing.EnlargeHorizontal;
  10. -    FEnlargeVertical:=SrcSizing.EnlargeVertical;
  11. -    FShrinkHorizontal:=SrcSizing.ShrinkHorizontal;
  12. -    FShrinkVertical:=SrcSizing.ShrinkVertical;
  13.      FEnlargeHorizontal:=SrcSizing.EnlargeHorizontal;
  14.      FEnlargeVertical:=SrcSizing.EnlargeVertical;
  15.      FShrinkHorizontal:=SrcSizing.ShrinkHorizontal;
  16. @@ -4061,10 +4057,6 @@ end;
  17.  function TControlChildSizing.IsEqual(Sizing: TControlChildSizing): Boolean;
  18.  begin
  19.    Result:=(FEnlargeHorizontal=Sizing.EnlargeHorizontal)
  20. -      and (FEnlargeVertical=Sizing.EnlargeVertical)
  21. -      and (FShrinkHorizontal=Sizing.ShrinkHorizontal)
  22. -      and (FShrinkVertical=Sizing.ShrinkVertical)
  23. -      and (FEnlargeHorizontal=Sizing.EnlargeHorizontal)
  24.        and (FEnlargeVertical=Sizing.EnlargeVertical)
  25.        and (FShrinkHorizontal=Sizing.ShrinkHorizontal)
  26.        and (FShrinkVertical=Sizing.ShrinkVertical)
« Last Edit: April 05, 2023, 11:04:33 am by lagprogramming »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10665
  • Debugger - SynEdit - and more
    • wiki
Re: Duplicate code removal in lcl/controls.pp
« Reply #1 on: April 03, 2023, 06:46:33 pm »
Please report on the bugtracker. Thanks

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4542
  • I like bugs.
Re: Duplicate code removal in lcl/controls.pp
« Reply #2 on: April 05, 2023, 12:38:40 am »
I removed the duplicate lines. Thanks for noticing them.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018