作者:姓赵的妖女 | 来源:互联网 | 2023-08-27 11:39
In the macro 'can_access_at_index' the buffer argument is checked against NULL, that is OK if this macro is not used inside loops like in 'parse_number' function.
In the code, usually the NULL test is performed in the top of every function, so the check inside 'can_access_at_index' can be removed. Example in parse_number' function:
if ((input_buffer == NULL) || (input_buffer->cOntent== NULL)) {
return false;
}
In the functions parse_array and parse object the buffer is used with no NULL check like in
if (input_buffer->depth >= CJSON_NESTING_LIMIT) {
But later in the same function we test NULL when using 'can_access_at_index'
该提问来源于开源项目:DaveGamble/cJSON
Actually it's not really measurable with your benchmark, at least not on my setup. The numbers are not stable enough to tell which one is faster.