ros2 / rmw_zenoh

RMW for ROS 2 using Zenoh as the middleware
Apache License 2.0
185 stars 34 forks source link

More cleanups around the code. #109

Closed clalancette closed 7 months ago

clalancette commented 7 months ago

As I was creating the design document, I noticed a few things around the code that could be cleaned up and made faster. This PR:

  1. Switches to using a keyexpression slice for creating keyexpressions. That way, we don't have to copy a string just to remove the final '/'.
  2. Makes sure that graph_sub_data_handler drops the keyexpression on all paths. In particular, on error paths we would forget to drop the keyexpression, so just use a make_scope_exit.
  3. Remove another unnecessary comment that has to do with porting to zenoh-pico.
  4. Remove an unnecessary use of malloc/memcpy/free when creating a map to use as an attachment for service calls. Since z_bytes_map_insert_by_copy will do a copy anyway, just pass in the array.
  5. When doing rmw_destroy_service, call z_undeclare_queryable to drop the queryable. I believe that this is functionally equivalent to z_drop, but I also think it is more self-documenting to use z_undeclare_queryable here.