为什么 SQLite 提供其代码的合并?

发布于 2024-07-14 07:33:47 字数 151 浏览 5 评论 0原文

每次我下载 SQLite 时,我都会发现他们提供了几个不同版本的源代码,这是我实际上从未见过任何其他项目所做的事情。 更重要的是,他们提供了源合并,即将所有文件合并为 3 个文件。 这是什么原因呢? 仅仅是编译速度吗? 或者有一些真正充分的理由吗? 其他项目是否使用源代码合并?

Every time I download SQLite, I come across the fact that they provide several different versions of their source code, which is something I've actually never seen any other project do. And more so they provide Amalgamations of Source, that kind of merge all their files into just 3 files. What's the reason for this? Is it just compilation speed? Or are there some really good reasons for it? Do other projects use Amalgamations of source code?

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

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

发布评论

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

评论(3

放血 2024-07-21 07:33:47

正如其有关合并的页面直接所述

除了使 SQLite 更容易合并到其他项目中之外,合并还使其运行速度更快。 当代码包含在单个翻译单元(例如合并单元)中时,许多编译器能够对代码进行额外的优化。 当我们使用合并来编译 SQLite 而不是单独的源文件时,我们测量到性能提高了 5% 到 10%。 这样做的缺点是额外的优化通常采用函数内联的形式,这往往会使生成的二进制图像的大小更大。

我本人认为融入其他项目是最大的好处。 它只是使编译变得更加容易。 没有构建脚本混乱以及拥有大量源文件所带来的任何其他后果。

As stated directly on their page about amalgamation

In addition to making SQLite easier to incorporate into other projects, the amalgamation also makes it run faster. Many compilers are able to do additional optimizations on code when it is contained with in a single translation unit such as it is in the amalgamation. We have measured performance improvements of between 5 and 10% when we use the amalgamation to compile SQLite rather than individual source files. The downside of this is that the additional optimizations often take the form of function inlining which tends to make the size of the resulting binary image larger.

I myself see's the incorporation into other projects the greatest benefit. It simply makes it much much easier to compile. No build script mess and whatever else follows from having a large collection of source files.

作死小能手 2024-07-21 07:33:47

这样做是为了更简单地合并到现有项目中。 将一个 .h 和一个 .c 添加到您的项目中,您就拥有了完整的 SQLite 引擎。

我很感激。 这让我少了一件需要担心的事情。

It's done to make incorporation into existing projects simpler. Add one .h and one .c to your project, and you have the full SQLite engine.

I appreciate it. It's one less thing I have to worry about.

只是在用心讲痛 2024-07-21 07:33:47

当我在 Windows 下使用 dev c++ 编译器尝试将合并文件分解为单个文件时,我遇到了很多问题。 因为我想让 sqlite 在 RTOS 中工作
名为 DJYOS,从单个文件更改代码比从合并文件更改代码更容易。

When I trid devide amalgamation file to individual files under windows with dev c++ compiler, I got a lots of question. Because I want make sqlite working in a RTOS which
named DJYOS, it's easier to change code from individual files than from amalgamation one.

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