Recent

Author Topic: Improvements  (Read 3368 times)

apexcol

  • Jr. Member
  • **
  • Posts: 54
Improvements
« on: December 13, 2017, 01:59:57 am »
Hi, I think it would be a good idea to put a place where all experienced pascal programmers should give improvements for the FreePascal code.

For example, I'd like FreePascal to change this
Code: Pascal  [Select][+][-]
  1. procedure TPoint.Offset(dx,dy : Longint);
  2. begin
  3.   x:=x+dx;
  4.   y:=y+dy;
  5. end;
on the file TYPSHRD.INC for this one...
Code: Pascal  [Select][+][-]
  1. procedure TPoint.Offset(dx,dy : Longint);
  2. begin
  3.   inc(x, dx);
  4.   inc(y, dy);
  5. end;      

Thanks in advance.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Improvements
« Reply #1 on: December 13, 2017, 08:38:48 am »
Well, experienced pascal programmers would be even more experienced once they learn to use trunk, create a patch and propose it into bugtracker:
https://bugs.freepascal.org/view_all_bug_page.php
http://wiki.freepascal.org/Creating_A_Patch
« Last Edit: December 13, 2017, 08:42:15 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: Improvements
« Reply #2 on: December 13, 2017, 08:47:22 am »
Those experienced programmers usually also examine the assembler output to check if it makes any difference (Positive or negative) before they submit a patch.
And discuss such syntax preferences first on the mailing list.
Code: Pascal  [Select][+][-]
  1. procedure TPoint.Offset(dx,dy : Longint);
  2. begin
  3.   x += dx;
  4.   y += dy;
  5. end;
     

Is what I -might - prefer..... :D Just teasing...

Note that in -04 all three generate the exact same code.

Such a patch will probably be applied if you add inline, and in that case just because of inline...Otherwise probably not.
Code: Pascal  [Select][+][-]
  1. procedure TPoint.Offset(dx,dy : Longint);inline;
« Last Edit: December 13, 2017, 11:27:49 am by Thaddy »
Specialize a type, not a var.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Improvements
« Reply #3 on: December 13, 2017, 11:10:21 am »
Note that in -04 all three generate the exact same code.
No need to be that high, AFAIK even -O1 (or -O2) already optimizes that statement to single inc instruction.
« Last Edit: December 14, 2017, 05:58:21 am by Leledumbo »

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: Improvements
« Reply #4 on: December 13, 2017, 11:24:09 am »
I did not check other optimizations. Just O4 and inline
Specialize a type, not a var.

 

TinyPortal © 2005-2018