-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
The header file is big, can we use what we need. #2134
Comments
This would be possible, but then we would juggle with some preprocessor macros to exclude undesired features. |
The underlying rationale of this request is confusing to me. If the extra code could be removed without affecting the use of the library within a given program, then that code is not part of the program in the first place and does not participate in the program's attack surface. C++ has a fundamental "only pay for what you use" principle at play here. including code does not mean that it participates in the program, you have to actually USE the code for it to actually have an effect. |
What I can think about in the long run is to better separate the internals of the JSON class from free functions working on JSON values. For instance, the binary formats are currently tied to the JSON class as But you are right - the argument of excluding buggy code is not really motivating that effort. |
One reason why I personally would love to have reduced headers is compile times. nlohmann/json is pretty much the highest compile time cost in our code base (next to std::variant), so if I could only include, what I actually need, that would probably at least half our compile time and memory usage. Some data for that from a basic ClangBuildAnalyzer run:
The mtx::events::to_json functions are super simple and just converts a struct with around 3 members to json, but they are called with around 20 different template arguments. I see no easy way to optimize it apart from simplifying the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Well, I think this issue still applies, but I guess nothing will be done to change that? (which is fine, there are probably better things to focus on.) |
No, I'm afraid this is as good as it gets. A shallow clone is cheap now, and anything beyond that would mean changing the repository's history. |
Well it still applies that including and using nlohmann/json.hpp has a large compile time overhead, which is unrelated to the download times, but I lack the expertise to say, if that is something that can be easily fixed without changing what nlohmann/json is about and what makes it great. |
Which feature do you want to see in the library?
The header file is big, and it has many extended features, such as binary formats (BSON, CBOR, MessagePack, and UBJSON), json patch.
However, sometimes we don't need the extended features.
Is there a way that we do not include these extended features so that the header file is small and when the extended features have bugs, we don't need to fix it.
How would the feature be usable for other users?
In some cases, the development guidelines we followed says that if the feature code has bugs, you must fix it whatever you use or not. Beacuse it provides a possible way to attack the program.
If we can use what we need or not include extended code , we can avoid attacking and don't need to spend times to fix it. And we can only focus on the changes in the core modules which we care about.
The text was updated successfully, but these errors were encountered: