Skip to content

Improve performance of adding item to array#448

Merged
Alanscut merged 14 commits into
DaveGamble:masterfrom
Alanscut:improve-add-item
Mar 24, 2020
Merged

Improve performance of adding item to array#448
Alanscut merged 14 commits into
DaveGamble:masterfrom
Alanscut:improve-add-item

Conversation

@Alanscut

Copy link
Copy Markdown
Collaborator

Changes:

@xiaomianhehe , would you like to review this pr?

Comment thread tests/misc_tests.c
str3 = cJSON_PrintUnformatted(root);
TEST_ASSERT_EQUAL_STRING(expected_json3, str3);
free(str3);

@xiaomianhehe xiaomianhehe Mar 19, 2020

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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?

@xiaomianhehe xiaomianhehe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants