Skip to content
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

Making some features compile time optional to reduce the code size. #245

Open
Tangerino opened this issue Feb 24, 2018 · 6 comments
Open
Milestone

Comments

@Tangerino
Copy link

I do have a use case where I don't need to encode JSON so I'd like to remove that code from the library. I've installed (quick & dirty) some ifdef and reduced by 60% the code size. A huge difference when using micro controllers.
Thanks

@FSMaxB
Copy link
Collaborator

FSMaxB commented Feb 24, 2018

My discussions with @ajaybhargav in #177 have led me to reconsider using compile configuration of the feature set.

The only thing that I am still unsure about is how fine the granularity should be.

Also I don't think I will be able to test all possible combinations if the test matrix gets too big.

@Tangerino
Copy link
Author

Thanks. I would say at least implement encode/decode options

@FSMaxB
Copy link
Collaborator

FSMaxB commented Feb 25, 2018

So my current plan is to do the following options:

  • parsing
  • printing
  • cJSON_Minify
  • cJSON_Duplicate
  • cJSON_Compare

In the future cJSON_Utils could then be included into cJSON guarded by feature flags.

I also though about making profiles. Like minimal and full.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Feb 25, 2018

This would then already be too much to test all configurations, at least in continuous integration, since 2^5=32. But it might be doable to build them all once before a release.

@Tangerino
Copy link
Author

Tangerino commented Feb 25, 2018 via email

@FSMaxB
Copy link
Collaborator

FSMaxB commented Feb 25, 2018

I don't really want to go lower than per function level with the compile time configuration.

UTF-16 to UTF-8 conversion is here to stay.

I have though of making the use of double runtime optional in the future in v2, see the newest idea on how the struct should look in the future #63 (comment). That can be combined with #186 by adding a new option to only parse all numbers as integers. When I get to that point, I have to think if it is possible to optionally get rid of the double related code altogether. This requires the code paths to be separate enough to make this possible.

@FSMaxB FSMaxB changed the title Reduce code removing features Making some features compile time optional to reduce the code size. Feb 25, 2018
@FSMaxB FSMaxB added this to the 1.8 milestone Feb 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants