Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-03

Not specifying the {$H+} degrades performance

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

If I have a .pas unit and forgot to specify the compiler mode line

   {$mode objfpc}{$H+}

what does FPC default to? Compiler Mode? Longstring or Shortstring?

I wrote a string tokenizer and did some time trials against an old tokenizer I used. First I forgot to include the compiler mode line above and did some test runs. I then noticed my mistake and added in that line and did some more test runs. The second set of tests where on avg 10% faster!

After some more testing I realized it is the {$H+} that gave me the performance boost. What does FPC default to? Why not default to {$H+} ?

Lazarus added the following compiler parameters:
---------------------------------------------------- -S2cgi -OG1 -gl -vewnhi -l
-Fu/opt/lazarus/components/fpcunit/lib/i386-linux/ -Fu/opt/lazarus/components/synedit/units/i386-linux/ -Fu../../3rdParty/tiOPF2/Source/Compilers/FPC/lib/i386-linux/ -Fu/home/graemeg/programming/3rdParty/FBlib/lib/i386-linux/ -Fu/opt/lazarus/lcl/units/i386-linux/
-Fu/opt/lazarus/lcl/units/i386-linux/gtk/
-Fu/opt/lazarus/packager/units/i386-linux/ -Fu. -ofpcunitproject1 -dUseCThreads -dLCL -dLCLgtk
----------------------------------------------------

Graeme Geldenhuys There's no place like S34° 03.168' E018° 49.342'
Jonas Maebe
to Graeme Geldenhuys
Graeme Geldenhuys wrote
If I have a .pas unit and forgot to specify the compiler mode line {$mode objfpc}{$H+} what does FPC default to? Compiler Mode? Longstring or Shortstring?

Shortstring. {$h+} is not longstring, but ansistring.

After some more testing I realized it is the {$H+} that gave me the performance boost. What does FPC default to? Why not default to {$H+} ?

Backwards compatibility. There are also many situations where ansistrings are slower than shortstrings.

Jonas

Graeme Geldenhuys
to Jonas Maebe

Ah, I see... Thanks for the quick reply.

Graeme.

Jonas Maebe wrote 18 lines
On 26 mrt 2007, at 12:54, Graeme Geldenhuys wrote: > If I have a .pas unit and forgot to specify the compiler mode line > {$mode objfpc}{$H+} > what does FPC default to? Compiler Mode? Longstring or Shortstring? Shortstring. {$h+} is not longstring, but ansistring. > After some more testing I realized it is the {$H+} that gave me the > performance boost. What does FPC default to? Why not default to {$H+} > ? Backwards compatibility. There are also many situations where ansistrings are slower than shortstrings. Jonas