如何识别并删除“使用条款”中未使用的单位? 在德尔福7中?

发布于 2024-07-21 04:24:35 字数 145 浏览 7 评论 0原文

在我的一些非常大的项目中,这应该会大大减少可执行文件的大小。 我确信还会有其他好处。

编辑:是否有一个实用程序可以扫描项目并自动删除多余的项目? 我确实有数百个项目,“自动删除”将是一等奖,尽管如果必须的话,我会在识别实用程序的帮助下采用手动方式。

This should reduce the executable size quite a bit in some of my very large projects. I am sure there would be other benefits too.

EDIT: Is there perhaps a utility that will scan the project and remove redundant ones automatically? I do have 100s of projects and "automatic remove" would be first prize although if I have to I will go the manual way with the help of identifying utilities.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

夜无邪 2024-07-28 04:24:35

您可能想看看 CnPack

CnPack 包含一个使用清理向导,它还没有让我失望。

You might want to take a look at at CnPack.

CnPack includes a Uses cleaner wizard wich hasn't failed me yet.

琉璃繁缕 2024-07-28 04:24:35

我曾经使用 Icarus 它给了我一份未使用的使用条目的报告。

从网页上

ICARUS 解析 Delphi 或 Borland Pascal 源代码并生成使用报告。 该报告将帮助您从使用列表中删除不需要的单位。 您还将知道哪些单元可以从接口使用列表移动到实现使用列表。

删除未使用的引用有多种好处:
维护更干净的代码,无需担心未使用的代码
未使用单元中的初始化和终结部分的代码未链接到
编译运行更流畅、更快

ICARUS 非常易于使用,只需选择一个源文件,设置一些选项,然后开始分析。 或者让内置向导引导您完成此过程。

ICARUS 是免费软件。

I used to use Icarus that gave me a report of unused uses entries.

From the web page

ICARUS parses Delphi or Borland Pascal source code and generates a Uses Report. This report will help you remove unneeded units from your uses lists. You will also know which units that can be moved from the interface uses list to the implementation uses list.

Removing unused uses references has multiple benefits:
Cleaner code to maintain, no need to bother about code that is not used
Code from initialization and finalization sections in unused units is not linked in
Compilation runs smoother and quicker

ICARUS is very easy to use, just select a source file, set a few options, and start analyzing. Or let the built-in wizard guide you through this process.

ICARUS is FREEWARE.

枉心 2024-07-28 04:24:35

这样的工具永远无法分析所使用单元的初始化或终结部分是否需要执行。 从使用中删除单元可能会导致不运行初始化和终结部分,从而导致错误。

Such a tool can never analyze if the initialization or finalization sections of a used unit need to be executed or not. Removing units from the uses could result in not running initialization and finalization sections and therefore result in bugs.

月下伊人醉 2024-07-28 04:24:35

如果您的代码可以使用 Free Pascal 进行编译,则 Free Pascal 编译器还会发出有关代码中未使用单元的提示。

另请参阅此 SO 条目,其中包含有关可能问题的其他信息,例如基于 RTTI 的方法:

https://stackoverflow.com/questions/605977/tools-to-detect-dead-code-in-delphi2007-or-above/

If your code can be compiled with Free Pascal, the Free Pascal compiler also will emit hints about unused units in your code.

See also this SO entry with additional information about possible problems, like RTTI based methods:

https://stackoverflow.com/questions/605977/tools-to-detect-dead-code-in-delphi2007-or-above/

隔纱相望 2024-07-28 04:24:35

请记住,链接器将删除任何无法调用的内容。 如果一个单元没有被使用并且没有初始化或终结,那么它无论如何都会被完全剥离。 初始化或终结中引用的任何内容都将保留,但一般来说这不会带来太多影响。

一个单元可能只包含初始化,因此全自动剥离无论如何都会受到限制。 仅以某种方式改变系统行为的单元很可能没有引用,但仍然需要。 (我想到了具有良好泄漏跟踪功能的替换内存管理器。虽然它确实有您可以参考的东西,但没有必要,只需使用它并获取泄漏报告即可。仔细检查您的代码。)

Remember that the linker will strip anything that can't be called. If no use is made of a unit and it has no initialization or finalization it's going to be completely stripped anyway. Anything referenced in the initialization or finalization will stay but in general this shouldn't bring in much anyway.

It's possible for a unit to consist of only initialization so full-auto stripping is limited anyway. Units which merely change system behavior in some fashion might very well have no references and yet be needed. (The replacement memory manager with good leak tracking comes to mind. While it does have things you can reference there's no need to, just use it and get the leak report. Nice double-check for your code.)

深海里的那抹蓝 2024-07-28 04:24:35

请参阅此处的一些答案。

See some of the answers here.

束缚m 2024-07-28 04:24:35

Peganza 有类似的工具:http://www.peganza.com/

Peganza has similar tools: http://www.peganza.com/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文