-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added forward declaration header json_forward.hpp. Minimise build times. #823
Added forward declaration header json_forward.hpp. Minimise build times. #823
Conversation
Hi! This is already done in #700, although not merged (yet). |
Thanks @theodelrieu, I see the changes in your pull request are numerous. Impressive! Any idea when your changes may be merged? Could my changes function as a half-way house? Do your changes preclude my changes from being merged? Further clarification would be much appreciated. |
@zerodefect Soon I hope! Well the main issue is that we still want to provide an amalgamated version of All of that work is already done on #700, I need to rebase to solve minor conflicts. Meanwhile you can use the If you have more questions, let me know :) |
@@ -29,6 +29,10 @@ SOFTWARE. | |||
#ifndef NLOHMANN_JSON_HPP | |||
#define NLOHMANN_JSON_HPP | |||
|
|||
|
|||
#include "json_forward.hpp" // Some forward declarations are re-used here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like breaking the header into two files at this moment. PR #700 proposes a restructuring into several files, but also provides a script to re-create a single header.
Sorry for not commenting earlier. As I wrote in #823 (review), I do not like the idea of splitting the header into several files. Furthermore, PR #700 already goes further and not only splits the code, but also provides a script to re-create a single header. Unless there I missed a strong argument for this PR, I would close it. |
This pull request aims to reduce compile time by the introduction of a header dedicated to providing forward declaration of nlohmann::json.
One of the great merits of the this library is that it is header only. Unfortunately, that does also come with some disadvantages, namely the compile times are often higher with such code dependencies.
This pull request introduces a 'json_forward.hpp' header file (similar to how Boost offer forward header files) in an attempt to try reduce build times.
Things to note (and some of these come down to personal preference):
Points to consider:
So I tried integrating these code changes with my own project and ran a comparison test.
Build time without forward declaration header:
Build time making extensive use of forward declaration header (where possible):
Please note that this test was not wholly scientific. I imagine mileage will vary across environments/compilers and the level of use of this library in the said project.
Tested with cmake and gcc 6.3 running on Ubuntu's 17.04 (Zesty).