From 2b2a40efbab2cd9adbbcc1c40fe39d8eb527ad1c Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 6 Nov 2024 18:24:42 +0100 Subject: [PATCH] feat: improve stirng/slice move --- src/collections/slice.c | 5 +---- src/collections/string.c | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/collections/slice.c b/src/collections/slice.c index 7cfe786f1..049721a8a 100644 --- a/src/collections/slice.c +++ b/src/collections/slice.c @@ -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); } diff --git a/src/collections/string.c b/src/collections/string.c index a2545e767..d15d1438e 100644 --- a/src/collections/string.c +++ b/src/collections/string.c @@ -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;