Skip to content

Commit

Permalink
Small shortcut for when item already equals replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
DonLoquacious committed Dec 11, 2023
1 parent ae304c3 commit 97e77c6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ks_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,12 @@ KS_DECLARE(ks_bool_t) ks_json_replace_item(ks_json_t *parent, ks_json_t **item,
return KS_FALSE;
}

if (replacement == *item) {
*item = NULL;

return KS_TRUE;
}

replacement->next = (*item)->next;
replacement->prev = (*item)->prev;

Expand Down

0 comments on commit 97e77c6

Please sign in to comment.