Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improve performance of adding item to array #448

Merged
merged 14 commits into from
Mar 24, 2020
Merged

Improve performance of adding item to array #448

merged 14 commits into from
Mar 24, 2020

Conversation

Alanscut
Copy link
Collaborator

Changes:

@xiaomianhehe , would you like to review this pr?

str3 = cJSON_PrintUnformatted(root);
TEST_ASSERT_EQUAL_STRING(expected_json3, str3);
free(str3);

Copy link
Contributor

@xiaomianhehe xiaomianhehe Mar 19, 2020

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

Copy link
Collaborator Author

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?

Copy link
Contributor

@xiaomianhehe xiaomianhehe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approve

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

Successfully merging this pull request may close these issues.

2 participants