Recent

Author Topic: Disable parsing of include files? [solved]  (Read 7650 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Disable parsing of include files?
« Reply #15 on: November 30, 2018, 12:05:53 am »
A more compact source is very important to me if the alternative is writing thousands of lines by hand. Maybe I'll find a more maintainable way, too.
Include files are not the only way.

1) You can write and run a preprocessor (project options > Compiler command > Execute before)

2) You can use generics

3) (I never said that, I deny it if anyone says I did...) {$macro on}
   not sure that will do much good in your case

4) For repeated editing tasks, look into editor macros (well, you still get the code duplication..., just some tool to maintain it)
   http://wiki.lazarus.freepascal.org/Editor_Macros_PascalScript

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Disable parsing of include files?
« Reply #16 on: November 30, 2018, 12:26:02 am »
I get the impression you are confusing Pascal with an interpreted script.
I'm deliberately using $ifdefs here, this is supposed to be resolved at compile time. (And no, inline doesn't always work - already tried that.)

If you are "fighting" a speed problem, there may be other ways.

If you are not sure where time goes, get a linux environment and use callgrind (part of valgrind). Dont just try to squeeze micro optimizations (like inline, or pointers). See why some code is called more often, and if it can be changed.

You may be able to build very optimized "case like" jump tables at runtime (once during initialization).
But that is all theoretical, I dont know the codebase....

Also review how you organize and store data. Every cache miss costs time. Sometimes compacter data (even if it requires an extra statement) can be faster. But that is hard to predict again.

- If you run with threads: there are currently speed improvements in the works, in fpc trunk.
- If you work with managed types (strings/dyn array), check "implicit exceptions" and turning them off.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Disable parsing of include files?
« Reply #17 on: November 30, 2018, 04:04:39 am »
I did not read the whole thread, so my apology if I repeated someone's answer.

Use macros:
Code: Pascal  [Select][+][-]
  1. unit U_Test;
  2. {$Macro ON}
  3. {$define macro_I_en:={$i I_en}}
  4. ...
  5. case i of
  6.         00:  {$define Phase00}  macro_I_en  {$undef Phase00};
  7.         01:  {$define Phase01}  macro_I_en  {$undef Phase01};
  8.         02:  {$define Phase02}  macro_I_en  {$undef Phase02};
  9. ...

According to FPC your sample produces more than 9000 lines.

creaothceann

  • Full Member
  • ***
  • Posts: 117
Re: Disable parsing of include files?
« Reply #18 on: November 30, 2018, 10:27:50 am »
@engkin: see above.

3) (I never said that, I deny it if anyone says I did...) {$macro on}
   not sure that will do much good in your case
Already tried that: ("$define Phase := 1" etc.), seemed to be slightly slower than just defining and undefining symbols. But I might have to use it later anyway.

If you are not sure where time goes, get a linux environment and use callgrind (part of valgrind). Dont just try to squeeze micro optimizations (like inline, or pointers). See why some code is called more often, and if it can be changed.
Yeah, probably going to set up a Linux installation at some point.

Also review how you organize and store data. Every cache miss costs time. Sometimes compacter data (even if it requires an extra statement) can be faster. But that is hard to predict again.
The virtual CPU's state is packed, fits into a cache line (64 bytes). The hot codepaths hopefully fit into the instruction cache, it might be faster to use non-inlined functions instead of unrolling everything. If I'm lucky, the whole thing with all the loaded data will fit into L3 caches.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Disable parsing of include files?
« Reply #19 on: November 30, 2018, 07:18:17 pm »
3) (I never said that, I deny it if anyone says I did...) {$macro on}
   not sure that will do much good in your case
Already tried that: ("$define Phase := 1" etc.), seemed to be slightly slower than just defining and undefining symbols. But I might have to use it later anyway.
Did you try to define just {$i I_en} as a macro, as in my post? That will prevent the IDE from going through the tree of included files and bring the editing speed back to normal.

creaothceann

  • Full Member
  • ***
  • Posts: 117
Re: Disable parsing of include files?
« Reply #20 on: November 30, 2018, 07:44:34 pm »
Did you try to define just {$i I_en} as a macro, as in my post?
Oh wow, that worked. :o Thanks!

(I'm surprised that the first "}" doesn't end the macro definition and that the IDE doesn't use it.)

 

TinyPortal © 2005-2018