4 ms·
> I obsess over clean code Yep, it shows. I got curious over the GP's comment, and I spot checked json.c[1] and json.h[2]. They're cleanly written, your data
by MonkeyClub 5y ago
> I obsess over clean code
Yep, it shows.
I got curious over the GP's comment, and I spot checked json.c[1] and json.h[2].
They're cleanly written, your data structures reflect your use and I can get an idea of what does what through the code alone.
Trying to figure out what could be considered obscure. For example would
if (!btc_amount_import(&x, obj->u.string.ptr))
return 0;
be considered obscure? Cause if you know the structure of a json_value, then you get what the phrase says.
Well thought out and cleanly written code, I'd say.
[1] https://github.com/chjj/mako/blob/master/src/json.c https://github.com/chjj/mako/blob/master/src/json.c
[2] https://github.com/chjj/mako/blob/master/include/mako/json.h https://github.com/chjj/mako/blob/master/include/mako/json.h
- chjj 5y agoNot sure. I suppose I could add a style or coding convention guide somewhere in the repo to code that may seem confusing initially. Basic rules are: return values on the left side of params, and functions generally return a boolean for success or failure. The function you mention is parsing a fixed-point integer string (from a json string) and returning an int64_t. It will return 0 if it's not a syntactically valid integer, or if there is some kind of overflow, etc.