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

Performance: should we use sscanf? #160

Closed
ysc3839 opened this issue Apr 26, 2017 · 2 comments
Closed

Performance: should we use sscanf? #160

ysc3839 opened this issue Apr 26, 2017 · 2 comments

Comments

@ysc3839
Copy link
Contributor

ysc3839 commented Apr 26, 2017

For example: plugins/cloudxns.c.
I use sscanf to parse domain info. But I think using strstr and strchr is better.

@troglobit
Copy link
Owner

It's not optimal, but not too bad. Sometimes code readability is to be preferred, in particular in cases when you look for a string in a context. Just looking for a substring with strstr() can be deceitful and give false positives unless you also look for surrounding text.

In the case of cloudxns.c I'd probably go for strtok() and strcmp() to split up the stream in {, }, and : separated tokens.

@troglobit
Copy link
Owner

Closing. We now have two (!) JSON implementations in Inadyn, so any changes to refactor/optimize performance should probably first start with refactoring this plugin to use include/jsmn.h (jasmine).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants