-
Notifications
You must be signed in to change notification settings - Fork 479
Description
Hello! I was working on an rcl client library and was using rclcpp (and rclpy) as reference implementation, and when working on TimeSource I found a potential issue.
Specifically, when looking at the TimeSource implementation for both rclpy and rclcpp, I noticed that for each time source, its associated clocks are stored in a vector.
Now apart from the premature-optimization-root-of-all-evil issue of having finds be linear in time here, I believe the fact that clocks are naively appended in attachClock would allow duplicates in the vector. Now the drawback is not the end of the world since it's just that the same clock would be updated more than once for each subscription callback but would it make sense to either:
- Do an
std::findcall inattachClockand print a warning + avoid appending if the clock already exists - Make the attached clocks storage structure a
unordered_set?
If any of these makes sense I'll be happy to open upstream PRs in both rclpy and rclcpp since they have the same implementation (rclpy is here)