-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Improve performance of adding item to array #448
Conversation
Co-authored-by: xiaomianhehe <[email protected]> Date: Tue Feb 18 11:54:23 2020 +0800
str3 = cJSON_PrintUnformatted(root); | ||
TEST_ASSERT_EQUAL_STRING(expected_json3, str3); | ||
free(str3); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//To cover more case, add below test would be better?
cJSON_AddItemToArray(array, item1);
cJSON_DeleteItemFromArray(array, 1);
str2 = cJSON_PrintUnformatted(root);
TEST_ASSERT_EQUAL_STRING(expected_json2, str2);
free(str2);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item1
has been freed during cJSON_DeleteItemFromArray(array, 0);
, so I have to copy it at first. besides, I think the test you supplemented won't pass: str2
is not equal expected_json2
.
could you provide a completely testcase? or use the insert a suggestion
(ctrl+g) to give me a more detail clue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approve
Changes:
@xiaomianhehe , would you like to review this pr?