Skip to content

Commit

Permalink
feat: improve stirng/slice move
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Nov 6, 2024
1 parent d5483c9 commit 2b2a40e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/collections/slice.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ z_result_t _z_slice_n_copy(_z_slice_t *dst, const _z_slice_t *src, size_t offset
}

void _z_slice_move(_z_slice_t *dst, _z_slice_t *src) {
dst->start = src->start;
dst->len = src->len;
dst->_delete_context = src->_delete_context;

*dst = *src;
_z_slice_reset(src);
}

Expand Down
2 changes: 1 addition & 1 deletion src/collections/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ z_result_t _z_string_copy_substring(_z_string_t *dst, const _z_string_t *src, si
return _z_slice_n_copy(&dst->_slice, &src->_slice, offset, len);
}

void _z_string_move(_z_string_t *dst, _z_string_t *src) { *dst = _z_string_steal(src); }
void _z_string_move(_z_string_t *dst, _z_string_t *src) { _z_slice_move(&dst->_slice, &src->_slice); }

_z_string_t _z_string_steal(_z_string_t *str) {
_z_string_t ret;
Expand Down

0 comments on commit 2b2a40e

Please sign in to comment.