troglobit / inadyn

In-a-Dyn is a dynamic DNS client with multiple SSL/TLS library support
https://troglobit.com/projects/inadyn/
GNU General Public License v2.0
965 stars 139 forks source link

Performance: should we use sscanf? #160

Closed ysc3839 closed 4 years ago

ysc3839 commented 7 years ago

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

troglobit commented 7 years ago

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 commented 4 years ago

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).