Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove clone for types which do not involve copying #13

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions include/zenoh-pico/api/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,20 +294,14 @@
* Returns the cloned instance of `x`.
*/
#define z_clone(x, y) _Generic((x), \
z_owned_keyexpr_t : z_keyexpr_clone, \
z_owned_session_t : z_session_clone, \
z_owned_subscriber_t : z_subscriber_clone, \
z_owned_publisher_t : z_publisher_clone, \
z_owned_queryable_t : z_queryable_clone, \
z_owned_query_t : z_query_clone, \
z_owned_sample_t : z_sample_clone, \
z_owned_bytes_t : z_bytes_clone, \
z_owned_encoding_t : z_encoding_clone, \
z_owned_reply_err_t : z_reply_err_clone, \
z_owned_reply_t : z_reply_clone, \
z_owned_hello_t : z_hello_clone, \
z_owned_string_t : z_string_clone, \
z_owned_string_array_t : z_string_array_clone, \
z_owned_config_t : z_config_clone \
)(&x, y)

Expand Down
12 changes: 6 additions & 6 deletions include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -1359,17 +1359,17 @@ _Z_OWNED_FUNCTIONS_DEF(string)
_Z_OWNED_FUNCTIONS_DEF(keyexpr)
_Z_OWNED_FUNCTIONS_NO_COPY_DEF(config)
_Z_OWNED_FUNCTIONS_DEF(session)
_Z_OWNED_FUNCTIONS_DEF(subscriber)
_Z_OWNED_FUNCTIONS_DEF(publisher)
_Z_OWNED_FUNCTIONS_DEF(queryable)
_Z_OWNED_FUNCTIONS_DEF(hello)
_Z_OWNED_FUNCTIONS_NO_COPY_DEF(subscriber)
_Z_OWNED_FUNCTIONS_NO_COPY_DEF(publisher)
_Z_OWNED_FUNCTIONS_NO_COPY_DEF(queryable)
_Z_OWNED_FUNCTIONS_NO_COPY_DEF(hello)
_Z_OWNED_FUNCTIONS_DEF(reply)
_Z_OWNED_FUNCTIONS_DEF(string_array)
_Z_OWNED_FUNCTIONS_NO_COPY_DEF(string_array)
_Z_OWNED_FUNCTIONS_DEF(sample)
_Z_OWNED_FUNCTIONS_DEF(query)
_Z_OWNED_FUNCTIONS_DEF(slice)
_Z_OWNED_FUNCTIONS_DEF(bytes)
_Z_OWNED_FUNCTIONS_DEF(reply_err)
_Z_OWNED_FUNCTIONS_NO_COPY_DEF(reply_err)
_Z_OWNED_FUNCTIONS_DEF(encoding)

_Z_OWNED_FUNCTIONS_CLOSURE_DEF(closure_sample)
Expand Down
10 changes: 5 additions & 5 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ int8_t z_keyexpr_as_view_string(const z_loaned_keyexpr_t *keyexpr, z_view_string
int8_t z_keyexpr_concat(z_owned_keyexpr_t *key, const z_loaned_keyexpr_t *left, const char *right, size_t len) {
z_internal_keyexpr_null(key);
if (len == 0) {
return z_keyexpr_clone(key, left);
return _z_keyexpr_copy(&key->_val, left);
} else if (right == NULL) {
return _Z_ERR_INVALID;
}
Expand Down Expand Up @@ -770,15 +770,15 @@ _Z_OWNED_FUNCTIONS_VALUE_IMPL(_z_string_t, string, _z_string_check, _z_string_nu
_Bool _z_value_check(const _z_value_t *value) {
return _z_encoding_check(&value->encoding) || _z_bytes_check(&value->payload);
}
_Z_OWNED_FUNCTIONS_VALUE_IMPL(_z_value_t, reply_err, _z_value_check, _z_value_null, _z_value_copy, _z_value_clear)
_Z_OWNED_FUNCTIONS_VALUE_NO_COPY_IMPL(_z_value_t, reply_err, _z_value_check, _z_value_null, _z_value_clear)

_Z_OWNED_FUNCTIONS_VALUE_IMPL(_z_keyexpr_t, keyexpr, _z_keyexpr_check, _z_keyexpr_null, _z_keyexpr_copy,
_z_keyexpr_clear)
_Z_VIEW_FUNCTIONS_IMPL(_z_keyexpr_t, keyexpr, _z_keyexpr_check, _z_keyexpr_null)
_Z_VIEW_FUNCTIONS_IMPL(_z_string_t, string, _z_string_check, _z_string_null)
_Z_VIEW_FUNCTIONS_IMPL(_z_slice_t, slice, _z_slice_check, _z_slice_empty)

_Z_OWNED_FUNCTIONS_VALUE_IMPL(_z_hello_t, hello, _z_hello_check, _z_hello_null, _z_hello_copy, _z_hello_clear)
_Z_OWNED_FUNCTIONS_VALUE_NO_COPY_IMPL(_z_hello_t, hello, _z_hello_check, _z_hello_null, _z_hello_clear)

z_id_t z_hello_zid(const z_loaned_hello_t *hello) { return hello->_zid; }

Expand Down Expand Up @@ -814,8 +814,8 @@ int8_t _z_string_array_copy(_z_string_svec_t *dst, const _z_string_svec_t *src)
return dst->_len == src->_len ? _Z_RES_OK : _Z_ERR_SYSTEM_OUT_OF_MEMORY;
}
_z_string_svec_t _z_string_array_null(void) { return _z_string_svec_make(0); }
_Z_OWNED_FUNCTIONS_VALUE_IMPL(_z_string_svec_t, string_array, _z_string_array_check, _z_string_array_null,
_z_string_array_copy, _z_string_svec_clear)
_Z_OWNED_FUNCTIONS_VALUE_NO_COPY_IMPL(_z_string_svec_t, string_array, _z_string_array_check, _z_string_array_null,
_z_string_svec_clear)
_Z_OWNED_FUNCTIONS_VALUE_IMPL(_z_slice_t, slice, _z_slice_check, _z_slice_empty, _z_slice_copy, _z_slice_clear)
_Z_OWNED_FUNCTIONS_VALUE_IMPL(_z_bytes_t, bytes, _z_bytes_check, _z_bytes_null, _z_bytes_copy, _z_bytes_drop)

Expand Down