Reputation: 6041
I am wondering if the following using unit order is correct.
uses
FastMM4 in 'Fast\FastMM4\FastMM4.pas',
VCLFixPack in 'VCLFixPack.pas',
FastMove in 'Fast\FastMove\FastMove.pas',
FastCode in 'Fast\FastCode\FastCode.pas',
FastMM4Messages in 'Fast\FastMM4\FastMM4Messages.pas',
Why should I bother with the order?
Upvotes: 3
Views: 668
Reputation: 613242
You have three separate pieces of code here:
It is important to install the replacement memory manager, FastMM, before any heap allocations are performed. So I think it is clear that must be the first unit to include. And you may as well keep the two FastMM units together.
The other units make changes to the code in memory, to fix bugs (VCLFixPack) or to improve performance (FastCode). Although you have separately identified FastMove
and FastCode
, in reality, the FastCode
unit actually installs a suite of improved functions, defined over a dozen separate separate units.
It seems quite likely that it would be important to install the VCL fixes before the VCL units are included. So VCLFixPack should appear before any VCL units.
As for FastCode, since it only influences performance, you could perfectly well use it at any point in the .dpr file. It probably does not matter if the initialization code runs with the vanilla RTL code. That said, for sake of consistency it makes sense to keep together all these units which change the behaviour of the runtime. So I would write your .dpr uses clause like this:
uses
FastMM4 in 'Fast\FastMM4\FastMM4.pas',
FastMM4Messages in 'Fast\FastMM4\FastMM4Messages.pas',
FastCode in 'Fast\FastCode\FastCode.pas',
VCLFixPack in 'VCLFixPack.pas',
....
I put FastCode
before VCLFixPack
because logically the RTL is at a lower level than the VCL. However, it does not matter either way around. But you've got to pick one, and that was my reasoning.
I also omitted an explicit reference to the FastMove
unit. That is used by FastCode
, along with a host of other units, and if you are going to omit the others, you may as well omit FastMove
.
Upvotes: 5
Reputation: 28826
There may be a few reasons:
Note that it is not guaranteed that the order is preserved. If one of the units uses another, that one must be loaded first. To make a unit really the very first, make it the first in the .dpr
or .dpk
file.
Upvotes: 7