I use cnPack Uses cleaner, but in general which are the downsides of having useless units?
I know some of them:
1) of course if the unit is never used across the full project there will be useless resource consuption
2) the code insight will give useless results
3) the code insight will be slower
But imagine a simple case:
No. In general smartlinking works like this:
Conclusion: the final .exe size is determined
Free Pascal roughly works in the same way, the defaults are just different; Debug is currently nearly always "in binary" (like TD32), and in snapshots, smartlinking is off by default. (in official releases it is on though).
Moreover one must not lose sight of the magnitude. Strutils in its entirety is like 15kb max.
(update 2011-11-01)
Got a remark from sb on this reply I liked to share:
Basically he shed doubt on the remark that enums are always linked in. Maybe the registering of a class that has a published property of the enum type drags them in. The reasoning makes sense, but I haven't tested it yet. So RTTI of enum directly can be only linked if typeinfo(tenumtype) is queried somewhere, or if it is used in a published section of the class which is used. (directly or typeinfo(theclass) is queried)
The biggest problem, to my mind, is that you can sometimes get caught out by Delphi scoping rules. If you have two identifiers with the same name in different units, then using this name refers to the one declared in the unit declared latest in the uses clause.
If you suffer from a problem due to this you can always fully specify the identifier. What I would really love to see would be compiler warnings to tell you if you are naming an identifier that whose identity is only determined by this latest declaration in uses clause scoping rule.
Delphi smart linker will ignore unused code so normally the presence of these "extra" units does not increase the size of the compiled program.
Here are some points i get from this link about downsides of unused units
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With