Skip to content

Commit

Permalink
libzfs_sendrecv: Avoid extra avl_find
Browse files Browse the repository at this point in the history
avl_add does avl_find internally, then avl_insert.  We're already doing
the avl_find, so using avl_insert directly avoids repeating the search.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #12967
  • Loading branch information
Ryan Moeller authored and behlendorf committed Feb 2, 2022
1 parent 1488e82 commit af2b1fb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/libzfs/libzfs_sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ fsavl_create(nvlist_t *fss)
* Note: if there are multiple snaps with the
* same GUID, we ignore all but one.
*/
if (avl_find(fsavl, fn, NULL) == NULL)
avl_add(fsavl, fn);
avl_index_t where = 0;
if (avl_find(fsavl, fn, &where) == NULL)
avl_insert(fsavl, fn, where);
else
free(fn);
}
Expand Down

0 comments on commit af2b1fb

Please sign in to comment.